aboutsummaryrefslogtreecommitdiffstats
path: root/utils/v4l2-ctl
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-04-20 11:46:44 -0700
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-04-21 10:53:53 +0200
commit2933f7fa494d50824ab2bfc73ccdca171cdd0b63 (patch)
tree72245f69474dedb02d32a2fcb32edaed33a579c6 /utils/v4l2-ctl
parent699126cffe02e05629a996c469d4d4fd385417c9 (diff)
treewide: replace C casts with C++
Also remove useless casts. Found with clang-tidy's google-readability-casting Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/v4l2-ctl')
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-common.cpp20
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-edid.cpp6
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-io.cpp4
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-meta.cpp8
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-modes.cpp12
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-overlay.cpp10
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-stds.cpp16
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-streaming.cpp44
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-vidcap.cpp4
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp12
10 files changed, 68 insertions, 68 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index ce6ac2fd..f2997951 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -314,8 +314,8 @@ static void list_devices()
card = mdi.driver;
}
} else {
- bus_info = (const char *)vcap.bus_info;
- card = (const char *)vcap.card;
+ bus_info = reinterpret_cast<const char *>(vcap.bus_info);
+ card = reinterpret_cast<const char *>(vcap.card);
}
close(fd);
if (err)
@@ -385,7 +385,7 @@ static std::string safename(const unsigned char *name)
static std::string safename(const char *name)
{
- return safename((const unsigned char *)name);
+ return safename(reinterpret_cast<const unsigned char *>(name));
}
static void print_qctrl(int fd, struct v4l2_query_ext_ctrl *queryctrl,
@@ -543,7 +543,7 @@ static int print_control(int fd, struct v4l2_query_ext_ctrl &qctrl, int show_men
qctrl.id < V4L2_CID_PRIVATE_BASE)) {
if (qctrl.type == V4L2_CTRL_TYPE_STRING) {
ext_ctrl.size = qctrl.maximum + 1;
- ext_ctrl.string = (char *)malloc(ext_ctrl.size);
+ ext_ctrl.string = static_cast<char *>(malloc(ext_ctrl.size));
ext_ctrl.string[0] = 0;
}
if (test_ioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls)) {
@@ -584,8 +584,8 @@ static int query_ext_ctrl_ioctl(int fd, struct v4l2_query_ext_ctrl &qctrl)
memcpy(qctrl.name, qc.name, sizeof(qctrl.name));
qctrl.minimum = qc.minimum;
if (qc.type == V4L2_CTRL_TYPE_BITMASK) {
- qctrl.maximum = (__u32)qc.maximum;
- qctrl.default_value = (__u32)qc.default_value;
+ qctrl.maximum = static_cast<__u32>(qc.maximum);
+ qctrl.default_value = static_cast<__u32>(qc.default_value);
} else {
qctrl.maximum = qc.maximum;
qctrl.default_value = qc.default_value;
@@ -840,7 +840,7 @@ void common_cmd(const std::string &media_bus_info, int ch, char *optarg)
}
break;
case OptSetPriority:
- prio = (enum v4l2_priority)strtoul(optarg, 0L, 0);
+ prio = static_cast<enum v4l2_priority>(strtoul(optarg, 0L, 0));
break;
case OptListDevices:
if (media_bus_info.empty())
@@ -1064,7 +1064,7 @@ static void print_array(const struct v4l2_query_ext_ctrl &qc, void *p)
switch (qc.type) {
case V4L2_CTRL_TYPE_U8:
for (i = from; i <= to; i++) {
- printf("%4d", ((__u8 *)p)[idx + i]);
+ printf("%4d", (static_cast<__u8 *>(p))[idx + i]);
if (i < to)
printf(", ");
}
@@ -1072,7 +1072,7 @@ static void print_array(const struct v4l2_query_ext_ctrl &qc, void *p)
break;
case V4L2_CTRL_TYPE_U16:
for (i = from; i <= to; i++) {
- printf("%6d", ((__u16 *)p)[idx + i]);
+ printf("%6d", (static_cast<__u16 *>(p))[idx + i]);
if (i < to)
printf(", ");
}
@@ -1080,7 +1080,7 @@ static void print_array(const struct v4l2_query_ext_ctrl &qc, void *p)
break;
case V4L2_CTRL_TYPE_U32:
for (i = from; i <= to; i++) {
- printf("%6d", ((__u32 *)p)[idx + i]);
+ printf("%6d", (static_cast<__u32 *>(p))[idx + i]);
if (i < to)
printf(", ");
}
diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
index 319cbb4b..366e6522 100644
--- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp
@@ -235,7 +235,7 @@ static void edid_add_block(struct v4l2_edid *e)
e->edid = NULL;
exit(1);
}
- e->edid = (unsigned char *)realloc(e->edid, e->blocks * 128);
+ e->edid = static_cast<unsigned char *>(realloc(e->edid, e->blocks * 128));
}
static void read_edid_file(FILE *f, struct v4l2_edid *e)
@@ -1332,7 +1332,7 @@ void edid_get(cv4l_fd &_fd)
exit(1);
}
}
- gedid.edid = (unsigned char *)malloc(gedid.blocks * 128);
+ gedid.edid = static_cast<unsigned char *>(malloc(gedid.blocks * 128));
if (doioctl(fd, VIDIOC_G_EDID, &gedid) == 0) {
if (options[OptFixEdidChecksums])
fix_edid(&gedid);
@@ -1344,7 +1344,7 @@ void edid_get(cv4l_fd &_fd)
}
if (options[OptInfoEdid]) {
info_edid.blocks = 2;
- info_edid.edid = (unsigned char *)malloc(info_edid.blocks * 128);
+ info_edid.edid = static_cast<unsigned char *>(malloc(info_edid.blocks * 128));
if (doioctl(fd, VIDIOC_G_EDID, &info_edid) == 0)
print_edid_mods(&info_edid);
free(info_edid.edid);
diff --git a/utils/v4l2-ctl/v4l2-ctl-io.cpp b/utils/v4l2-ctl/v4l2-ctl-io.cpp
index dc2756c8..1130fdc0 100644
--- a/utils/v4l2-ctl/v4l2-ctl-io.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-io.cpp
@@ -184,7 +184,7 @@ void io_list(cv4l_fd &_fd)
printf("\tType : 0x%08X (%s)\n", vin.type, inputtype2s(vin.type));
printf("\tAudioset : 0x%08X\n", vin.audioset);
printf("\tTuner : 0x%08X\n", vin.tuner);
- printf("\tStandard : 0x%016llX (%s)\n", (unsigned long long)vin.std,
+ printf("\tStandard : 0x%016llX (%s)\n", static_cast<unsigned long long>(vin.std),
std2s(vin.std).c_str());
printf("\tStatus : 0x%08X (%s)\n", vin.status, in_status2s(vin.status).c_str());
printf("\tCapabilities: 0x%08X (%s)\n", vin.capabilities, input_cap2s(vin.capabilities).c_str());
@@ -204,7 +204,7 @@ void io_list(cv4l_fd &_fd)
printf("\tName : %s\n", vout.name);
printf("\tType : 0x%08X (%s)\n", vout.type, outputtype2s(vout.type));
printf("\tAudioset : 0x%08X\n", vout.audioset);
- printf("\tStandard : 0x%016llX (%s)\n", (unsigned long long)vout.std,
+ printf("\tStandard : 0x%016llX (%s)\n", static_cast<unsigned long long>(vout.std),
std2s(vout.std).c_str());
printf("\tCapabilities: 0x%08X (%s)\n", vout.capabilities, output_cap2s(vout.capabilities).c_str());
vout.index++;
diff --git a/utils/v4l2-ctl/v4l2-ctl-meta.cpp b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
index b1288297..0e1071b0 100644
--- a/utils/v4l2-ctl/v4l2-ctl-meta.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-meta.cpp
@@ -155,10 +155,10 @@ void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
switch (fmt.g_pixelformat()) {
case V4L2_META_FMT_UVC:
fprintf(f, "UVC: ");
- vbuf = (vivid_uvc_meta_buf *)q.g_dataptr(buf.g_index(), 0);
+ vbuf = static_cast<vivid_uvc_meta_buf *>(q.g_dataptr(buf.g_index(), 0));
fprintf(f, "%.6fs sof: %4d len: %u flags: 0x%02x",
- (double)vbuf->ns / 1000000000.0,
+ static_cast<double>(vbuf->ns) / 1000000000.0,
vbuf->sof,
vbuf->length,
vbuf->flags);
@@ -174,7 +174,7 @@ void print_meta_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
break;
case V4L2_META_FMT_VIVID:
fprintf(f, "VIVID:");
- vbuf_out = (vivid_meta_out_buf *)q.g_dataptr(buf.g_index(), 0);
+ vbuf_out = static_cast<vivid_meta_out_buf *>(q.g_dataptr(buf.g_index(), 0));
fprintf(f, " brightness: %u contrast: %u saturation: %u hue: %d\n",
vbuf_out->brightness, vbuf_out->contrast,
@@ -189,7 +189,7 @@ void meta_fillbuffer(cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
switch (fmt.g_pixelformat()) {
case V4L2_META_FMT_VIVID:
- vbuf = (vivid_meta_out_buf *)q.g_dataptr(buf.g_index(), 0);
+ vbuf = static_cast<vivid_meta_out_buf *>(q.g_dataptr(buf.g_index(), 0));
vbuf->brightness = buf.g_sequence() % 192 + 64;
vbuf->contrast = (buf.g_sequence() + 10) % 192 + 64;
vbuf->saturation = (buf.g_sequence() + 20) % 256;
diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
index 9db07f1a..b311ce5d 100644
--- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
@@ -224,7 +224,7 @@ bool calc_cvt_modeline(int image_width, int image_height,
if (ideal_blank_duty_cycle < 20 * HV_FACTOR)
ideal_blank_duty_cycle = 20 * HV_FACTOR;
- h_blank = active_h_pixel * (long long)ideal_blank_duty_cycle /
+ h_blank = active_h_pixel * static_cast<long long>(ideal_blank_duty_cycle) /
(100 * HV_FACTOR - ideal_blank_duty_cycle);
h_blank -= h_blank % (2 * CVT_CELL_GRAN);
@@ -238,7 +238,7 @@ bool calc_cvt_modeline(int image_width, int image_height,
h_bp = h_blank / 2;
h_fp = h_blank - h_bp - h_sync;
- pixel_clock = ((long long)total_h_pixel * HV_FACTOR * 1000000)
+ pixel_clock = (static_cast<long long>(total_h_pixel) * HV_FACTOR * 1000000)
/ h_period;
pixel_clock -= pixel_clock % clk_gran;
} else {
@@ -468,10 +468,10 @@ bool calc_gtf_modeline(int image_width, int image_height,
v_blank = v_sync + v_bp + v_fp;
total_v_lines = active_v_lines + v_blank;
- v_refresh_est = (2 * HV_FACTOR * (long long)1000000) /
+ v_refresh_est = (2 * HV_FACTOR * static_cast<long long>(1000000)) /
(h_period_est * (2 * total_v_lines + interlace) / HV_FACTOR);
- h_period = ((long long)h_period_est * v_refresh_est) /
+ h_period = (static_cast<long long>(h_period_est) * v_refresh_est) /
(v_refresh * HV_FACTOR);
if (!reduced_blanking)
@@ -481,7 +481,7 @@ bool calc_gtf_modeline(int image_width, int image_height,
ideal_blank_duty_cycle = (GTF_S_C_PRIME * HV_FACTOR) -
GTF_S_M_PRIME * h_period / 1000;
- h_blank = active_h_pixel * (long long)ideal_blank_duty_cycle /
+ h_blank = active_h_pixel * static_cast<long long>(ideal_blank_duty_cycle) /
(100 * HV_FACTOR - ideal_blank_duty_cycle);
h_blank = ((h_blank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN))
* (2 * GTF_CELL_GRAN);
@@ -493,7 +493,7 @@ bool calc_gtf_modeline(int image_width, int image_height,
h_fp = h_blank / 2 - h_sync;
h_bp = h_fp + h_sync;
- pixel_clock = ((long long)total_h_pixel * HV_FACTOR * 1000000)
+ pixel_clock = (static_cast<long long>(total_h_pixel) * HV_FACTOR * 1000000)
/ h_period;
/* Not sure if clock value needs to be truncated to multiple
* of 25000. The formula given in standard does not indicate
diff --git a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
index 162248bc..4c9609d6 100644
--- a/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-overlay.cpp
@@ -402,12 +402,12 @@ static void do_try_set_overlay(struct v4l2_format &fmt, int fd)
win.bitmap = NULL;
if (keep_old_bitmap) {
- bitmap = (unsigned char *)calloc(1, stride * win.w.height);
+ bitmap = static_cast<unsigned char *>(calloc(1, stride * win.w.height));
win.bitmap = bitmap;
}
if (keep_old_clip) {
if (win.clipcount)
- cliplist = (struct v4l2_clip *)malloc(win.clipcount * sizeof(*cliplist));
+ cliplist = static_cast<struct v4l2_clip *>(malloc(win.clipcount * sizeof(*cliplist)));
win.clips = cliplist;
}
if (keep_old_clip || keep_old_bitmap)
@@ -435,7 +435,7 @@ static void do_try_set_overlay(struct v4l2_format &fmt, int fd)
if (!bitmap_rects.empty()) {
free(bitmap);
stride = (win.w.width + 7) / 8;
- bitmap = (unsigned char *)calloc(1, stride * win.w.height);
+ bitmap = static_cast<unsigned char *>(calloc(1, stride * win.w.height));
win.bitmap = bitmap;
for (unsigned i = 0; i < bitmap_rects.size(); i++) {
const v4l2_rect &r = bitmap_rects[i];
@@ -518,8 +518,8 @@ void overlay_get(cv4l_fd &_fd)
unsigned stride = (fmt.fmt.win.w.width + 7) / 8;
if (fmt.fmt.win.clipcount)
- fmt.fmt.win.clips = (struct v4l2_clip *)malloc(fmt.fmt.win.clipcount * sizeof(clips[0]));
- bitmap = (unsigned char *)calloc(1, stride * fmt.fmt.win.w.height);
+ fmt.fmt.win.clips = static_cast<struct v4l2_clip *>(malloc(fmt.fmt.win.clipcount * sizeof(clips[0])));
+ bitmap = static_cast<unsigned char *>(calloc(1, stride * fmt.fmt.win.w.height));
fmt.fmt.win.bitmap = bitmap;
doioctl(fd, VIDIOC_G_FMT, &fmt);
printfmt(fd, fmt);
diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index d2cbae74..7ba44ae3 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -379,7 +379,7 @@ static void print_dv_timings(const struct v4l2_dv_timings *t)
if (options[OptConcise]) {
printf("\t%dx%d%c%.2f %s\n", bt->width, bt->height,
bt->interlaced ? 'i' : 'p',
- (double)bt->pixelclock /
+ static_cast<double>(bt->pixelclock) /
(tot_width * (tot_height / (bt->interlaced ? 2 : 1))),
dvflags2s(bt->vsync, bt->flags).c_str());
break;
@@ -399,10 +399,10 @@ static void print_dv_timings(const struct v4l2_dv_timings *t)
printf("\tPixelclock: %lld Hz", bt->pixelclock);
if (bt->width && bt->height) {
if (bt->interlaced)
- printf(" (%.2f fields per second)", (double)bt->pixelclock /
+ printf(" (%.2f fields per second)", static_cast<double>(bt->pixelclock) /
(tot_width * (tot_height / 2)));
else
- printf(" (%.2f frames per second)", (double)bt->pixelclock /
+ printf(" (%.2f frames per second)", static_cast<double>(bt->pixelclock) /
(tot_width * tot_height));
}
printf("\n");
@@ -495,7 +495,7 @@ void stds_set(cv4l_fd &_fd)
}
}
if (doioctl(fd, VIDIOC_S_STD, &standard) == 0)
- printf("Standard set to %08llx\n", (unsigned long long)standard);
+ printf("Standard set to %08llx\n", static_cast<unsigned long long>(standard));
}
if (options[OptSetDvBtTimings]) {
@@ -585,7 +585,7 @@ void stds_get(cv4l_fd &_fd)
if (options[OptGetStandard]) {
if (doioctl(fd, VIDIOC_G_STD, &standard) == 0) {
- printf("Video Standard = 0x%08llx\n", (unsigned long long)standard);
+ printf("Video Standard = 0x%08llx\n", static_cast<unsigned long long>(standard));
printf("\t%s\n", std2s(standard, "\n\t").c_str());
}
}
@@ -624,7 +624,7 @@ void stds_get(cv4l_fd &_fd)
if (options[OptQueryStandard]) {
if (doioctl(fd, VIDIOC_QUERYSTD, &standard) == 0) {
- printf("Video Standard = 0x%08llx\n", (unsigned long long)standard);
+ printf("Video Standard = 0x%08llx\n", static_cast<unsigned long long>(standard));
printf("\t%s\n", std2s(standard, "\n\t").c_str());
}
}
@@ -647,12 +647,12 @@ void stds_list(cv4l_fd &_fd)
while (test_ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) {
if (options[OptConcise]) {
printf("\t%2d: 0x%016llX %s\n", vs.index,
- (unsigned long long)vs.id, vs.name);
+ static_cast<unsigned long long>(vs.id), vs.name);
} else {
if (vs.index)
printf("\n");
printf("\tIndex : %d\n", vs.index);
- printf("\tID : 0x%016llX\n", (unsigned long long)vs.id);
+ printf("\tID : 0x%016llX\n", static_cast<unsigned long long>(vs.id));
printf("\tName : %s\n", vs.name);
printf("\tFrame period: %d/%d\n",
vs.frameperiod.numerator,
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index d9a307f9..de40c5ad 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -253,7 +253,7 @@ double fps_timestamps::fps()
double period = sum / cnt;
double fps = 1.0 / period;
- first += (unsigned)(ts[prev_idx] - first);
+ first += static_cast<unsigned>(ts[prev_idx] - first);
return fps;
};
@@ -510,7 +510,7 @@ static void print_buffer(FILE *f, struct v4l2_buffer &buf)
fprintf(f, "\tLength : %u\n", buf.length);
fprintf(f, "\tBytesused: %u\n", buf.bytesused);
fprintf(f, "\tTimestamp: %llu.%06llus (%s, %s)\n",
- (__u64)buf.timestamp.tv_sec, (__u64)buf.timestamp.tv_usec,
+ static_cast<__u64>(buf.timestamp.tv_sec), static_cast<__u64>(buf.timestamp.tv_usec),
timestamp_type2s(buf.flags).c_str(), timestamp_src2s(buf.flags).c_str());
if (buf.flags & V4L2_BUF_FLAG_TIMECODE) {
static const int fps_types[] = { 0, 24, 25, 30, 50, 60 };
@@ -721,9 +721,9 @@ void streaming_cmd(int ch, char *optarg)
if (speed > 3)
speed = 3;
if (ch == OptStreamOutHorSpeed)
- stream_out_hor_mode = (tpg_move_mode)(speed + 3);
+ stream_out_hor_mode = static_cast<tpg_move_mode>(speed + 3);
else
- stream_out_vert_mode = (tpg_move_mode)(speed + 3);
+ stream_out_vert_mode = static_cast<tpg_move_mode>(speed + 3);
break;
case OptStreamOutPercFill:
stream_out_perc_fill = strtoul(optarg, 0L, 0);
@@ -1023,7 +1023,7 @@ static bool fill_buffer_from_file(cv4l_fd &fd, cv4l_queue &q, cv4l_buffer &b,
read_u32(fin); // ignore field
read_u32(fin); // ignore flags
for (unsigned j = 0; j < q.g_num_planes(); j++) {
- __u8 *buf = (__u8 *)q.g_dataptr(b.g_index(), j);
+ __u8 *buf = static_cast<__u8 *>(q.g_dataptr(b.g_index(), j));
sz = read_u32(fin);
if (sz != V4L_STREAM_PACKET_FRAME_VIDEO_SIZE_PLANE_HDR) {
@@ -1052,7 +1052,7 @@ static bool fill_buffer_from_file(cv4l_fd &fd, cv4l_queue &q, cv4l_buffer &b,
fprintf(stderr, "error reading %d bytes\n", sz);
return false;
}
- if ((__u32)n == sz)
+ if (static_cast<__u32>(n) == sz)
break;
offset += n;
sz -= n;
@@ -1108,10 +1108,10 @@ restart:
}
if (fmt.g_pixelformat() == V4L2_PIX_FMT_FWHT_STATELESS)
- res = read_fwht_frame(fmt, (unsigned char *)buf, fin,
+ res = read_fwht_frame(fmt, static_cast<unsigned char *>(buf), fin,
sz, expected_len, buf_len);
else if (support_out_crop && v4l2_fwht_find_pixfmt(fmt.g_pixelformat()))
- res = read_write_padded_frame(fmt, (unsigned char *)buf,
+ res = read_write_padded_frame(fmt, static_cast<unsigned char *>(buf),
fin, sz, expected_len, buf_len, true);
else
sz = fread(buf, 1, expected_len, fin);
@@ -1197,7 +1197,7 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
for (p = 0; p < fmt.g_num_planes(); p++)
tpg_s_bytesperline(&tpg, p,
fmt.g_bytesperline(p));
- tpg_s_pattern(&tpg, (tpg_pattern)stream_pat);
+ tpg_s_pattern(&tpg, static_cast<tpg_pattern>(stream_pat));
tpg_s_mv_hor_mode(&tpg, stream_out_hor_mode);
tpg_s_mv_vert_mode(&tpg, stream_out_vert_mode);
tpg_s_show_square(&tpg, stream_out_square);
@@ -1215,7 +1215,7 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
tpg_s_pixel_aspect(&tpg, aspect);
break;
default:
- tpg_s_pixel_aspect(&tpg, (tpg_pixel_aspect)stream_out_pixel_aspect);
+ tpg_s_pixel_aspect(&tpg, static_cast<tpg_pixel_aspect>(stream_out_pixel_aspect));
break;
}
field = output_field;
@@ -1245,7 +1245,7 @@ static int do_setup_out_buffers(cv4l_fd &fd, cv4l_queue &q, FILE *fin, bool qbuf
if (can_fill) {
for (unsigned j = 0; j < q.g_num_planes(); j++)
- tpg_fillbuffer(&tpg, stream_out_std, j, (u8 *)q.g_dataptr(i, j));
+ tpg_fillbuffer(&tpg, stream_out_std, j, static_cast<u8 *>(q.g_dataptr(i, j)));
}
}
if (is_meta)
@@ -1318,7 +1318,7 @@ static void write_buffer_to_file(cv4l_fd &fd, cv4l_queue &q, cv4l_buffer &buf,
for (unsigned j = 0; j < buf.g_num_planes(); j++) {
__u32 used = buf.g_bytesused(j);
unsigned offset = buf.g_data_offset(j);
- u8 *p = (u8 *)q.g_dataptr(buf.g_index(), j) + offset;
+ u8 *p = static_cast<u8 *>(q.g_dataptr(buf.g_index(), j)) + offset;
if (ctx) {
comp_ptr[j] = fwht_compress(ctx, p,
@@ -1365,10 +1365,10 @@ static void write_buffer_to_file(cv4l_fd &fd, cv4l_queue &q, cv4l_buffer &buf,
if (host_fd_to >= 0)
sz = fwrite(comp_ptr[j] + offset, 1, used, fout);
else if (support_cap_compose && v4l2_fwht_find_pixfmt(fmt.g_pixelformat()))
- read_write_padded_frame(fmt, (u8 *)q.g_dataptr(buf.g_index(), j) + offset,
+ read_write_padded_frame(fmt, static_cast<u8 *>(q.g_dataptr(buf.g_index(), j)) + offset,
fout, sz, used, used, false);
else
- sz = fwrite((u8 *)q.g_dataptr(buf.g_index(), j) + offset, 1, used, fout);
+ sz = fwrite(static_cast<u8 *>(q.g_dataptr(buf.g_index(), j)) + offset, 1, used, fout);
if (sz != used)
fprintf(stderr, "%u != %u\n", sz, used);
@@ -1500,7 +1500,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
unsigned data_offset = cap->g_data_offset(j);
if (q.g_memory() == V4L2_MEMORY_USERPTR) {
- buf.s_userptr((u8 *)cap->g_userptr(j) + data_offset, j);
+ buf.s_userptr(static_cast<u8 *>(cap->g_userptr(j)) + data_offset, j);
buf.s_bytesused(cap->g_bytesused(j) - data_offset, j);
buf.s_data_offset(0, j);
} else if (q.g_memory() == V4L2_MEMORY_DMABUF) {
@@ -1551,7 +1551,7 @@ static int do_handle_out(cv4l_fd &fd, cv4l_queue &q, FILE *fin, cv4l_buffer *cap
if (!fin && stream_out_refresh) {
for (unsigned j = 0; j < buf.g_num_planes(); j++)
tpg_fillbuffer(&tpg, stream_out_std, j,
- (u8 *)q.g_dataptr(buf.g_index(), j));
+ static_cast<u8 *>(q.g_dataptr(buf.g_index(), j)));
}
if (is_meta)
meta_fillbuffer(buf, fmt, q);
@@ -1683,13 +1683,13 @@ static FILE *open_output_file(cv4l_fd &fd)
fprintf(stderr, "no such host %s\n", host_to);
exit(0);
}
- memset((char *)&serv_addr, 0, sizeof(serv_addr));
+ memset(reinterpret_cast<char *>(&serv_addr), 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
- memcpy((char *)&serv_addr.sin_addr.s_addr,
- (char *)server->h_addr,
+ memcpy(reinterpret_cast<char *>(&serv_addr.sin_addr.s_addr),
+ server->h_addr,
server->h_length);
serv_addr.sin_port = htons(host_port_to);
- if (connect(host_fd_to, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (connect(host_fd_to, reinterpret_cast<struct sockaddr *>(&serv_addr), sizeof(serv_addr)) < 0) {
fprintf(stderr, "could not connect\n");
exit(0);
}
@@ -1941,13 +1941,13 @@ static FILE *open_input_file(cv4l_fd &fd, __u32 type)
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(host_port_from);
- if (bind(listen_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (bind(listen_fd, reinterpret_cast<struct sockaddr *>(&serv_addr), sizeof(serv_addr)) < 0) {
fprintf(stderr, "could not bind\n");
exit(1);
}
listen(listen_fd, 1);
clilen = sizeof(cli_addr);
- host_fd_from = accept(listen_fd, (struct sockaddr *)&cli_addr, &clilen);
+ host_fd_from = accept(listen_fd, reinterpret_cast<struct sockaddr *>(&cli_addr), &clilen);
if (host_fd_from < 0) {
fprintf(stderr, "could not accept\n");
exit(1);
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
index 8f87ecbd..a9ef8eed 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -365,7 +365,7 @@ void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
'.', ',', ':', ';', '!', '|', 'i', 'c',
'n', 'o', 'm', 'I', 'C', 'N', 'O', 'M',
};
- __s16 *vbuf = (__s16 *)q.g_dataptr(buf.g_index(), 0);
+ __s16 *vbuf = static_cast<__s16 *>(q.g_dataptr(buf.g_index(), 0));
__u32 x, y;
switch (fmt.g_pixelformat()) {
@@ -374,7 +374,7 @@ void print_touch_buffer(FILE *f, cv4l_buffer &buf, cv4l_fmt &fmt, cv4l_queue &q)
fprintf(f, "TD16: ");
for (x = 0; x < fmt.g_width(); x++, vbuf++) {
- __s16 v = (__s16)le16toh(*vbuf);
+ __s16 v = static_cast<__s16>(le16toh(*vbuf));
if (!options[OptConcise])
fprintf(f, "% 4d", v);
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 1866172f..42889ef8 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -396,7 +396,7 @@ static std::string printfmtname(int fd, __u32 type, __u32 pixfmt)
fmt.type = type;
while (test_ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
if (fmt.pixelformat == pixfmt)
- return s + (const char *)fmt.description + ")";
+ return s + reinterpret_cast<const char *>(fmt.description) + ")";
fmt.index++;
}
return "";
@@ -476,7 +476,7 @@ void printfmt(int fd, const struct v4l2_format &vfmt)
}
printf("\tClip Bitmap : %s", vfmt.fmt.win.bitmap ? "Yes, " : "No\n");
if (vfmt.fmt.win.bitmap) {
- unsigned char *bitmap = (unsigned char *)vfmt.fmt.win.bitmap;
+ unsigned char *bitmap = static_cast<unsigned char *>(vfmt.fmt.win.bitmap);
unsigned stride = (vfmt.fmt.win.w.width + 7) / 8;
unsigned cnt = 0;
@@ -493,7 +493,7 @@ void printfmt(int fd, const struct v4l2_format &vfmt)
printf("\tSampling Rate : %u Hz\n", vfmt.fmt.vbi.sampling_rate);
printf("\tOffset : %u samples (%g secs after leading edge)\n",
vfmt.fmt.vbi.offset,
- (double)vfmt.fmt.vbi.offset / (double)vfmt.fmt.vbi.sampling_rate);
+ static_cast<double>(vfmt.fmt.vbi.offset) / static_cast<double>(vfmt.fmt.vbi.sampling_rate));
printf("\tSamples per Line: %u\n", vfmt.fmt.vbi.samples_per_line);
printf("\tSample Format : '%s'\n", fcc2s(vfmt.fmt.vbi.sample_format).c_str());
printf("\tStart 1st Field : %u\n", vfmt.fmt.vbi.start[0]);
@@ -657,7 +657,7 @@ void print_video_formats_ext(cv4l_fd &fd, __u32 type)
int parse_subopt(char **subs, const char * const *subopts, char **value)
{
- int opt = getsubopt(subs, (char * const *)subopts, value);
+ int opt = getsubopt(subs, const_cast<char * const *>(subopts), value);
if (opt == -1) {
fprintf(stderr, "Invalid suboptions specified\n");
@@ -886,7 +886,7 @@ int parse_selection_target(const char *s, unsigned int &target)
static void print_event(const struct v4l2_event *ev)
{
printf("%lld.%06ld: event %u, pending %u: ",
- (__u64)ev->timestamp.tv_sec, ev->timestamp.tv_nsec / 1000,
+ static_cast<__u64>(ev->timestamp.tv_sec), ev->timestamp.tv_nsec / 1000,
ev->sequence, ev->pending);
switch (ev->type) {
case V4L2_EVENT_VSYNC:
@@ -1154,7 +1154,7 @@ int main(int argc, char **argv)
if (ch == -1)
break;
- options[(int)ch] = 1;
+ options[ch] = 1;
if (!option_index) {
for (i = 0; long_options[i].val; i++) {
if (long_options[i].val == ch) {

Privacy Policy