clang-tidy: use nullptr
PATCH 1/2 clang-tidy: use nullptr
Found with modernize-use-nullptr
Signed-off-by Rosen Penev <[email protected]>
--- utils/cec-compliance/cec-compliance.cpp | 154 +++--- utils/cec-compliance/cec-test-adapter.cpp | 26 +- utils/cec-compliance/cec-test-power.cpp | 22 +- utils/cec-compliance/cec-test.cpp | 4 +- utils/cec-ctl/cec-ctl.cpp | 240 ++++----- utils/cec-follower/cec-follower.cpp | 44 +- utils/cec-follower/cec-processing.cpp | 16 +- utils/common/media-info.cpp | 20 +- utils/common/v4l2-info.cpp | 38 +- utils/libcecutil/cec-info.cpp | 8 +- utils/libcecutil/cec-log.cpp | 4 +- utils/libcecutil/cec-parse.cpp | 6 +- utils/rds-ctl/rds-ctl.cpp | 58 +-- utils/v4l2-compliance/v4l2-compliance.cpp | 78 +-- utils/v4l2-compliance/v4l2-test-buffers.cpp | 58 +-- utils/v4l2-compliance/v4l2-test-colors.cpp | 2 +- utils/v4l2-compliance/v4l2-test-controls.cpp | 6 +- utils/v4l2-compliance/v4l2-test-debug.cpp | 2 +- utils/v4l2-compliance/v4l2-test-formats.cpp | 4 +- utils/v4l2-compliance/v4l2-test-io-config.cpp | 2 +- utils/v4l2-compliance/v4l2-test-media.cpp | 8 +- utils/v4l2-ctl/v4l2-ctl-common.cpp | 30 +- utils/v4l2-ctl/v4l2-ctl-edid.cpp | 40 +- utils/v4l2-ctl/v4l2-ctl-io.cpp | 8 +- utils/v4l2-ctl/v4l2-ctl-meta.cpp | 6 +- utils/v4l2-ctl/v4l2-ctl-misc.cpp | 16 +- utils/v4l2-ctl/v4l2-ctl-overlay.cpp | 52 +- utils/v4l2-ctl/v4l2-ctl-sdr.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl-selection.cpp | 20 +- utils/v4l2-ctl/v4l2-ctl-stds.cpp | 12 +- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 72 +-- utils/v4l2-ctl/v4l2-ctl-subdev.cpp | 56 +-- utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 18 +- utils/v4l2-ctl/v4l2-ctl-vbi.cpp | 18 +- utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 12 +- utils/v4l2-ctl/v4l2-ctl-vidout.cpp | 2 +- utils/v4l2-ctl/v4l2-ctl.cpp | 468 +++++++++--------- utils/v4l2-dbg/v4l2-dbg.cpp | 58 +-- 38 files changed, 845 insertions(+), 845 deletions(-)
utils/cec-compliance/cec-compliance.cpp +77 -77
@@ -105,70 +105,70 @@ unsigned reply_threshold = 1000; time_t long_timeout = 60; static struct option long_options[] = { - {"device", required_argument, 0, OptSetDevice}, - {"adapter", required_argument, 0, OptSetAdapter}, - {"driver", required_argument, 0, OptSetDriver}, - {"help", no_argument, 0, OptHelp}, - {"no-warnings", no_argument, 0, OptNoWarnings}, - {"exit-on-fail", no_argument, 0, OptExitOnFail}, - {"exit-on-warn", no_argument, 0, OptExitOnWarn}, - {"remote", optional_argument, 0, OptRemote}, - {"list-tests", no_argument, 0, OptListTests}, - {"expect", required_argument, 0, OptExpect}, - {"expect-with-no-warnings", required_argument, 0, OptExpectWithNoWarnings}, - {"timeout", required_argument, 0, OptTimeout}, - {"trace", no_argument, 0, OptTrace}, - {"verbose", no_argument, 0, OptVerbose}, - {"color", required_argument, 0, OptColor}, - {"skip-info", no_argument, 0, OptSkipInfo}, - {"wall-clock", no_argument, 0, OptWallClock}, - {"interactive", no_argument, 0, OptInteractive}, - {"reply-threshold", required_argument, 0, OptReplyThreshold}, - - {"test-adapter", no_argument, 0, OptTestAdapter}, - {"test-fuzzing", no_argument, 0, OptTestFuzzing}, - {"test-core", no_argument, 0, OptTestCore}, - {"test-audio-rate-control", no_argument, 0, OptTestAudioRateControl}, - {"test-audio-return-channel-control", no_argument, 0, OptTestARCControl}, - {"test-capability-discovery-and-control", no_argument, 0, OptTestCapDiscoveryControl}, - {"test-deck-control", no_argument, 0, OptTestDeckControl}, - {"test-device-menu-control", no_argument, 0, OptTestDeviceMenuControl}, - {"test-device-osd-transfer", no_argument, 0, OptTestDeviceOSDTransfer}, - {"test-dynamic-auto-lipsync", no_argument, 0, OptTestDynamicAutoLipsync}, - {"test-osd-display", no_argument, 0, OptTestOSDDisplay}, - {"test-one-touch-play", no_argument, 0, OptTestOneTouchPlay}, - {"test-one-touch-record", no_argument, 0, OptTestOneTouchRecord}, - {"test-power-status", no_argument, 0, OptTestPowerStatus}, - {"test-remote-control-passthrough", no_argument, 0, OptTestRemoteControlPassthrough}, - {"test-routing-control", no_argument, 0, OptTestRoutingControl}, - {"test-system-audio-control", no_argument, 0, OptTestSystemAudioControl}, - {"test-system-information", no_argument, 0, OptTestSystemInformation}, - {"test-timer-programming", no_argument, 0, OptTestTimerProgramming}, - {"test-tuner-control", no_argument, 0, OptTestTunerControl}, - {"test-vendor-specific-commands", no_argument, 0, OptTestVendorSpecificCommands}, - {"test-standby-resume", no_argument, 0, OptTestStandbyResume}, - - {"skip-test-audio-rate-control", no_argument, 0, OptSkipTestAudioRateControl}, - {"skip-test-audio-return-channel-control", no_argument, 0, OptSkipTestARCControl}, - {"skip-test-capability-discovery-and-control", no_argument, 0, OptSkipTestCapDiscoveryControl}, - {"skip-test-deck-control", no_argument, 0, OptSkipTestDeckControl}, - {"skip-test-device-menu-control", no_argument, 0, OptSkipTestDeviceMenuControl}, - {"skip-test-device-osd-transfer", no_argument, 0, OptSkipTestDeviceOSDTransfer}, - {"skip-test-dynamic-auto-lipsync", no_argument, 0, OptSkipTestDynamicAutoLipsync}, - {"skip-test-osd-display", no_argument, 0, OptSkipTestOSDDisplay}, - {"skip-test-one-touch-play", no_argument, 0, OptSkipTestOneTouchPlay}, - {"skip-test-one-touch-record", no_argument, 0, OptSkipTestOneTouchRecord}, - {"skip-test-power-status", no_argument, 0, OptSkipTestPowerStatus}, - {"skip-test-remote-control-passthrough", no_argument, 0, OptSkipTestRemoteControlPassthrough}, - {"skip-test-routing-control", no_argument, 0, OptSkipTestRoutingControl}, - {"skip-test-system-audio-control", no_argument, 0, OptSkipTestSystemAudioControl}, - {"skip-test-system-information", no_argument, 0, OptSkipTestSystemInformation}, - {"skip-test-timer-programming", no_argument, 0, OptSkipTestTimerProgramming}, - {"skip-test-tuner-control", no_argument, 0, OptSkipTestTunerControl}, - {"skip-test-vendor-specific-commands", no_argument, 0, OptSkipTestVendorSpecificCommands}, - {"skip-test-standby-resume", no_argument, 0, OptSkipTestStandbyResume}, - {"version", no_argument, 0, OptVersion}, - {0, 0, 0, 0} + {"device", required_argument, nullptr, OptSetDevice}, + {"adapter", required_argument, nullptr, OptSetAdapter}, + {"driver", required_argument, nullptr, OptSetDriver}, + {"help", no_argument, nullptr, OptHelp}, + {"no-warnings", no_argument, nullptr, OptNoWarnings}, + {"exit-on-fail", no_argument, nullptr, OptExitOnFail}, + {"exit-on-warn", no_argument, nullptr, OptExitOnWarn}, + {"remote", optional_argument, nullptr, OptRemote}, + {"list-tests", no_argument, nullptr, OptListTests}, + {"expect", required_argument, nullptr, OptExpect}, + {"expect-with-no-warnings", required_argument, nullptr, OptExpectWithNoWarnings}, + {"timeout", required_argument, nullptr, OptTimeout}, + {"trace", no_argument, nullptr, OptTrace}, + {"verbose", no_argument, nullptr, OptVerbose}, + {"color", required_argument, nullptr, OptColor}, + {"skip-info", no_argument, nullptr, OptSkipInfo}, + {"wall-clock", no_argument, nullptr, OptWallClock}, + {"interactive", no_argument, nullptr, OptInteractive}, + {"reply-threshold", required_argument, nullptr, OptReplyThreshold}, + + {"test-adapter", no_argument, nullptr, OptTestAdapter}, + {"test-fuzzing", no_argument, nullptr, OptTestFuzzing}, + {"test-core", no_argument, nullptr, OptTestCore}, + {"test-audio-rate-control", no_argument, nullptr, OptTestAudioRateControl}, + {"test-audio-return-channel-control", no_argument, nullptr, OptTestARCControl}, + {"test-capability-discovery-and-control", no_argument, nullptr, OptTestCapDiscoveryControl}, + {"test-deck-control", no_argument, nullptr, OptTestDeckControl}, + {"test-device-menu-control", no_argument, nullptr, OptTestDeviceMenuControl}, + {"test-device-osd-transfer", no_argument, nullptr, OptTestDeviceOSDTransfer}, + {"test-dynamic-auto-lipsync", no_argument, nullptr, OptTestDynamicAutoLipsync}, + {"test-osd-display", no_argument, nullptr, OptTestOSDDisplay}, + {"test-one-touch-play", no_argument, nullptr, OptTestOneTouchPlay}, + {"test-one-touch-record", no_argument, nullptr, OptTestOneTouchRecord}, + {"test-power-status", no_argument, nullptr, OptTestPowerStatus}, + {"test-remote-control-passthrough", no_argument, nullptr, OptTestRemoteControlPassthrough}, + {"test-routing-control", no_argument, nullptr, OptTestRoutingControl}, + {"test-system-audio-control", no_argument, nullptr, OptTestSystemAudioControl}, + {"test-system-information", no_argument, nullptr, OptTestSystemInformation}, + {"test-timer-programming", no_argument, nullptr, OptTestTimerProgramming}, + {"test-tuner-control", no_argument, nullptr, OptTestTunerControl}, + {"test-vendor-specific-commands", no_argument, nullptr, OptTestVendorSpecificCommands}, + {"test-standby-resume", no_argument, nullptr, OptTestStandbyResume}, + + {"skip-test-audio-rate-control", no_argument, nullptr, OptSkipTestAudioRateControl}, + {"skip-test-audio-return-channel-control", no_argument, nullptr, OptSkipTestARCControl}, + {"skip-test-capability-discovery-and-control", no_argument, nullptr, OptSkipTestCapDiscoveryControl}, + {"skip-test-deck-control", no_argument, nullptr, OptSkipTestDeckControl}, + {"skip-test-device-menu-control", no_argument, nullptr, OptSkipTestDeviceMenuControl}, + {"skip-test-device-osd-transfer", no_argument, nullptr, OptSkipTestDeviceOSDTransfer}, + {"skip-test-dynamic-auto-lipsync", no_argument, nullptr, OptSkipTestDynamicAutoLipsync}, + {"skip-test-osd-display", no_argument, nullptr, OptSkipTestOSDDisplay}, + {"skip-test-one-touch-play", no_argument, nullptr, OptSkipTestOneTouchPlay}, + {"skip-test-one-touch-record", no_argument, nullptr, OptSkipTestOneTouchRecord}, + {"skip-test-power-status", no_argument, nullptr, OptSkipTestPowerStatus}, + {"skip-test-remote-control-passthrough", no_argument, nullptr, OptSkipTestRemoteControlPassthrough}, + {"skip-test-routing-control", no_argument, nullptr, OptSkipTestRoutingControl}, + {"skip-test-system-audio-control", no_argument, nullptr, OptSkipTestSystemAudioControl}, + {"skip-test-system-information", no_argument, nullptr, OptSkipTestSystemInformation}, + {"skip-test-timer-programming", no_argument, nullptr, OptSkipTestTimerProgramming}, + {"skip-test-tuner-control", no_argument, nullptr, OptSkipTestTunerControl}, + {"skip-test-vendor-specific-commands", no_argument, nullptr, OptSkipTestVendorSpecificCommands}, + {"skip-test-standby-resume", no_argument, nullptr, OptSkipTestStandbyResume}, + {"version", no_argument, nullptr, OptVersion}, + {nullptr, 0, nullptr, 0} }; #define STR(x) #x
@@ -268,7 +268,7 @@ static std::string ts2s(__u64 ts) return buf; } clock_gettime(CLOCK_MONOTONIC, &now); - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); diff = now.tv_sec * 1000000000ULL + now.tv_nsec - ts; sub.tv_sec = diff / 1000000000ULL; sub.tv_usec = (diff % 1000000000ULL) / 1000;
@@ -815,7 +815,7 @@ static bool wait_for_hpd(struct node *node, bool send_image_view_on) { int fd = node->fd; int flags = fcntl(node->fd, F_GETFL); - time_t t = time(NULL); + time_t t = time(nullptr); fcntl(node->fd, F_SETFL, flags | O_NONBLOCK); for (;;) {
@@ -825,7 +825,7 @@ static bool wait_for_hpd(struct node *node, bool send_image_view_on) FD_ZERO(&ex_fds); FD_SET(fd, &ex_fds); - res = select(fd + 1, NULL, NULL, &ex_fds, &tv); + res = select(fd + 1, nullptr, nullptr, &ex_fds, &tv); if (res < 0) { fail("select failed with error %d\n", errno); return false;
@@ -839,7 +839,7 @@ static bool wait_for_hpd(struct node *node, bool send_image_view_on) break; } - if (send_image_view_on && time(NULL) - t > TX_WAIT_FOR_HPD) { + if (send_image_view_on && time(nullptr) - t > TX_WAIT_FOR_HPD) { struct cec_msg image_view_on_msg; // So the HPD is gone (possibly due to a standby), but
@@ -852,7 +852,7 @@ static bool wait_for_hpd(struct node *node, bool send_image_view_on) send_image_view_on = false; } - if (time(NULL) - t > TX_WAIT_FOR_HPD + TX_WAIT_FOR_HPD_RETURN) { + if (time(nullptr) - t > TX_WAIT_FOR_HPD + TX_WAIT_FOR_HPD_RETURN) { fail("timed out after %d s waiting for HPD to return\n", TX_WAIT_FOR_HPD + TX_WAIT_FOR_HPD_RETURN); return false;
@@ -1103,11 +1103,11 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la) /* RC Profile and Device Features are assumed to be 1 byte. As of CEC 2.0 only 1 byte is used, but this might be extended in future versions. */ __u8 cec_version, all_device_types; - const __u8 *rc_profile = NULL, *dev_features = NULL; + const __u8 *rc_profile = nullptr, *dev_features = nullptr; cec_ops_report_features(&msg, &cec_version, &all_device_types, &rc_profile, &dev_features); - if (rc_profile == NULL || dev_features == NULL) + if (rc_profile == nullptr || dev_features == nullptr) return; node->remote[i].rc_profile = *rc_profile; node->remote[i].dev_features = *dev_features;
@@ -1128,8 +1128,8 @@ static void topology_probe_device(struct node *node, unsigned i, unsigned la) int main(int argc, char **argv) { std::string device; - const char *driver = NULL; - const char *adapter = NULL; + const char *driver = nullptr; + const char *adapter = nullptr; char short_options[26 * 2 * 2 + 1]; int remote_la = -1; bool test_remote = false;
@@ -1140,7 +1140,7 @@ int main(int argc, char **argv) int i; const char *env_media_apps_color = getenv("MEDIA_APPS_COLOR"); - srandom(time(NULL)); + srandom(time(nullptr)); if (!env_media_apps_color || !strcmp(env_media_apps_color, "auto")) show_colors = isatty(STDOUT_FILENO); else if (!strcmp(env_media_apps_color, "always"))
@@ -1207,10 +1207,10 @@ int main(int argc, char **argv) adapter = optarg; break; case OptReplyThreshold: - reply_threshold = strtoul(optarg, NULL, 0); + reply_threshold = strtoul(optarg, nullptr, 0); break; case OptTimeout: - long_timeout = strtoul(optarg, NULL, 0); + long_timeout = strtoul(optarg, nullptr, 0); break; case OptColor: if (!strcmp(optarg, "always"))
@@ -1243,7 +1243,7 @@ int main(int argc, char **argv) break; case OptRemote: if (optarg) { - remote_la = strtoul(optarg, NULL, 0); + remote_la = strtoul(optarg, nullptr, 0); if (remote_la < 0 || remote_la > 15) { fprintf(stderr, "--test: invalid remote logical address\n"); usage();
utils/cec-compliance/cec-test-adapter.cpp +13 -13
@@ -38,7 +38,7 @@ static int testCap(struct node *node) struct cec_caps caps; memset(&caps, 0xff, sizeof(caps)); - fail_on_test(doioctl(node, CEC_ADAP_G_CAPS, NULL) != EFAULT); + fail_on_test(doioctl(node, CEC_ADAP_G_CAPS, nullptr) != EFAULT); fail_on_test(doioctl(node, CEC_ADAP_G_CAPS, &caps)); fail_on_test(caps.available_log_addrs == 0 || caps.available_log_addrs > CEC_MAX_LOG_ADDRS);
@@ -53,9 +53,9 @@ static int testInvalidIoctls(struct node *node) unsigned ioc = _IOC(_IOC_NONE, type, 0xff, 0); unsigned char buf[0x4000] = {}; - fail_on_test(doioctl(node, ioc, NULL) != ENOTTY); + fail_on_test(doioctl(node, ioc, nullptr) != ENOTTY); ioc = _IOC(_IOC_NONE, type, 0, 0x3fff); - fail_on_test(doioctl(node, ioc, NULL) != ENOTTY); + fail_on_test(doioctl(node, ioc, nullptr) != ENOTTY); ioc = _IOC(_IOC_READ, type, 0, 0x3fff); fail_on_test(doioctl(node, ioc, buf) != ENOTTY); fail_on_test(check_0(buf, sizeof(buf)));
@@ -224,7 +224,7 @@ static int testAdapLogAddrs(struct node *node) fail("Unknown event %d\n", ev.event); break; } - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); } } while (!res); fail_on_test(doioctl(node, CEC_ADAP_S_LOG_ADDRS, &clear));
@@ -234,7 +234,7 @@ static int testAdapLogAddrs(struct node *node) res = doioctl(node, CEC_DQEVENT, &ev); fail_on_test(res && res != EAGAIN); if (res) - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); } while (res); fail_on_test(ev.flags & CEC_EVENT_FL_INITIAL_STATE); fail_on_test(ev.ts == 0);
@@ -249,7 +249,7 @@ static int testAdapLogAddrs(struct node *node) res = doioctl(node, CEC_DQEVENT, &ev); fail_on_test(res && res != EAGAIN); if (res) - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); } while (res); fail_on_test(ev.flags & CEC_EVENT_FL_INITIAL_STATE); fail_on_test(ev.ts == 0);
@@ -448,13 +448,13 @@ static int testTransmit(struct node *node) } if (tested_valid_la) { - time_t cur_t = time(NULL), t; + time_t cur_t = time(nullptr), t; time_t last_t = cur_t + 7; unsigned max_cnt = 0; unsigned cnt = 0; do { - t = time(NULL); + t = time(nullptr); if (t != cur_t) { if (cnt > max_cnt) max_cnt = cnt;
@@ -472,13 +472,13 @@ static int testTransmit(struct node *node) } if (tested_invalid_la) { - time_t cur_t = time(NULL), t; + time_t cur_t = time(nullptr), t; time_t last_t = cur_t + 7; unsigned max_cnt = 0; unsigned cnt = 0; do { - t = time(NULL); + t = time(nullptr); if (t != cur_t) { if (cnt > max_cnt) max_cnt = cnt;
@@ -1062,7 +1062,7 @@ static int testLostMsgs(struct node *node) if (res == EBUSY) { struct timeval tv = { 0, 10000 }; // 10 ms - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); got_busy = true; } else if (!got_busy) { tx_queue_depth++;
@@ -1098,7 +1098,7 @@ static int testLostMsgs(struct node *node) unsigned pending_tx_rx_aborted_msgs = 0; unsigned pending_rx_msgs = 0; unsigned pending_rx_cec_version_msgs = 0; - time_t start = time(NULL); + time_t start = time(nullptr); __u8 last_init = 0xff; __u64 last_ts = 0; unsigned tx_repeats = 0;
@@ -1211,7 +1211,7 @@ static int testLostMsgs(struct node *node) if (pending_quick_msgs < pending_msgs) printf("\t\tReceived %d messages immediately, and %d over %ld seconds\n", pending_quick_msgs, pending_msgs - pending_quick_msgs, - time(NULL) - start); + time(nullptr) - start); } if (fail_msg) return fail("There were %d messages in the receive queue for %d transmits\n",
utils/cec-compliance/cec-test-power.cpp +11 -11
@@ -255,19 +255,19 @@ static bool wait_changing_power_status(struct node *node, unsigned me, unsigned unsigned &unresponsive_time) { __u8 old_status; - time_t t = time(NULL); + time_t t = time(nullptr); announce("Checking for power status change. This may take up to %llu s.", (long long)long_timeout); if (!get_power_status(node, me, la, old_status)) return false; - while (time(NULL) - t < long_timeout) { + while (time(nullptr) - t < long_timeout) { __u8 power_status; if (!get_power_status(node, me, la, power_status)) { /* Some TVs become completely unresponsive when transitioning between power modes. Register that this happens, but continue the test. */ - unresponsive_time = time(NULL) - t; + unresponsive_time = time(nullptr) - t; } else if (old_status != power_status) { new_status = power_status; return true;
@@ -283,25 +283,25 @@ static bool poll_stable_power_status(struct node *node, unsigned me, unsigned la { bool transient = false; unsigned time_to_transient = 0; - time_t t = time(NULL); + time_t t = time(nullptr); /* Some devices can use several seconds to transition from one power state to another, so the power state must be repeatedly polled */ announce("Waiting for new stable power status. This may take up to %llu s.", (long long)long_timeout); - while (time(NULL) - t < long_timeout) { + while (time(nullptr) - t < long_timeout) { __u8 power_status; if (!get_power_status(node, me, la, power_status)) { /* Some TVs become completely unresponsive when transitioning between power modes. Register that this happens, but continue the test. */ - unresponsive_time = time(NULL) - t; + unresponsive_time = time(nullptr) - t; sleep(SLEEP_POLL_POWER_STATUS); continue; } if (!transient && (power_status == CEC_OP_POWER_STATUS_TO_ON || power_status == CEC_OP_POWER_STATUS_TO_STANDBY)) { - time_to_transient = time(NULL) - t; + time_to_transient = time(nullptr) - t; transient = true; warn_once_on_test(expected_status == CEC_OP_POWER_STATUS_ON && power_status == CEC_OP_POWER_STATUS_TO_STANDBY);
@@ -565,7 +565,7 @@ static int power_state_transitions(struct node *node, unsigned me, unsigned la, cec_msg_init(&msg, me, la); cec_msg_standby(&msg); fail_on_test(!transmit_timeout(node, &msg)); - time_t start = time(NULL); + time_t start = time(nullptr); int res = util_receive(node, la, long_timeout * 1000, &msg, CEC_MSG_STANDBY, CEC_MSG_REPORT_POWER_STATUS); fail_on_test(!res);
@@ -576,7 +576,7 @@ static int power_state_transitions(struct node *node, unsigned me, unsigned la, info("so any kernel released after January 2020 should have this fix.\n"); return OK_PRESUMED; } - if (time(NULL) - start > 3) + if (time(nullptr) - start > 3) warn("The first Report Power Status broadcast arrived > 3s after sending <Standby>\n"); if (msg.msg[2] == CEC_OP_POWER_STATUS_STANDBY) return 0;
@@ -603,10 +603,10 @@ static int power_state_transitions(struct node *node, unsigned me, unsigned la, fail_on_test(doioctl(node, CEC_TRANSMIT, &msg)); } fail_on_test(!(msg.tx_status & CEC_TX_STATUS_OK)); - start = time(NULL); + start = time(nullptr); fail_on_test(util_receive(node, la, long_timeout * 1000, &msg, opcode, CEC_MSG_REPORT_POWER_STATUS) <= 0); - if (time(NULL) - start > 3) + if (time(nullptr) - start > 3) warn("The first Report Power Status broadcast arrived > 3s after sending <%s>\n", opcode == CEC_MSG_IMAGE_VIEW_ON ? "Image View On" : "Set Stream Path"); if (msg.msg[2] == CEC_OP_POWER_STATUS_ON)
utils/cec-compliance/cec-test.cpp +2 -2
@@ -152,7 +152,7 @@ int system_info_give_features(struct node *node, unsigned me, unsigned la, bool const __u8 *rc_profile, *dev_features; cec_ops_report_features(&msg, &cec_version, &all_device_types, &rc_profile, &dev_features); - fail_on_test(rc_profile == NULL || dev_features == NULL); + fail_on_test(rc_profile == nullptr || dev_features == nullptr); info("All Device Types: \t\t%s\n", cec_all_dev_types2s(all_device_types).c_str()); info("RC Profile: \t%s", cec_rc_src_prof2s(*rc_profile, "").c_str()); info("Device Features: \t%s", cec_dev_feat2s(*dev_features, "").c_str());
@@ -1529,7 +1529,7 @@ int setExpectedResult(char *optarg, bool no_warnings) std::string name = safename(optarg); if (mapTests.find(name) == mapTests.end()) return 1; - mapTests[name] = strtoul(equal + 1, NULL, 0); + mapTests[name] = strtoul(equal + 1, nullptr, 0); mapTestsNoWarnings[name] = no_warnings; return 0; }
utils/cec-ctl/cec-ctl.cpp +120 -120
470 lines not on this page · raw message
utils/cec-follower/cec-follower.cpp +22 -22
74 lines not on this page · raw message
utils/cec-follower/cec-processing.cpp +8 -8
@@ -147,7 +147,7 @@ static bool exit_standby(struct node *node) node->state.power_status == CEC_OP_POWER_STATUS_TO_STANDBY) { node->state.old_power_status = node->state.power_status; node->state.power_status = CEC_OP_POWER_STATUS_ON; - node->state.power_status_changed_time = time(NULL); + node->state.power_status_changed_time = time(nullptr); dev_info("Changing state to on\n"); return true; }
@@ -160,7 +160,7 @@ static bool enter_standby(struct node *node) node->state.power_status == CEC_OP_POWER_STATUS_TO_ON) { node->state.old_power_status = node->state.power_status; node->state.power_status = CEC_OP_POWER_STATUS_STANDBY; - node->state.power_status_changed_time = time(NULL); + node->state.power_status_changed_time = time(nullptr); dev_info("Changing state to standby\n"); return true; }
@@ -222,7 +222,7 @@ static bool pa_is_upstream_from(__u16 pa1, __u16 pa2) static __u8 current_power_state(struct node *node) { - time_t t = time(NULL); + time_t t = time(nullptr); if (t - node->state.power_status_changed_time <= time_to_transient) return node->state.old_power_status;
@@ -864,10 +864,10 @@ void testProcessing(struct node *node, bool wallclock) unsigned me; unsigned last_poll_la = 15; __u8 last_pwr_state = current_power_state(node); - time_t last_pwr_status_toggle = time(NULL); + time_t last_pwr_status_toggle = time(nullptr); clock_gettime(CLOCK_MONOTONIC, &start_monotonic); - gettimeofday(&start_timeofday, NULL); + gettimeofday(&start_timeofday, nullptr); doioctl(node, CEC_S_MODE, &mode); doioctl(node, CEC_ADAP_G_LOG_ADDRS, &laddrs);
@@ -885,7 +885,7 @@ void testProcessing(struct node *node, bool wallclock) FD_ZERO(&ex_fds); FD_SET(fd, &rd_fds); FD_SET(fd, &ex_fds); - res = select(fd + 1, &rd_fds, NULL, &ex_fds, &timeval); + res = select(fd + 1, &rd_fds, nullptr, &ex_fds, &timeval); if (res < 0) break; if (FD_ISSET(fd, &ex_fds)) {
@@ -967,8 +967,8 @@ void testProcessing(struct node *node, bool wallclock) } if (node->state.toggle_power_status && cec_has_tv(1 << me) && - (time(NULL) - last_pwr_status_toggle > node->state.toggle_power_status)) { - last_pwr_status_toggle = time(NULL); + (time(nullptr) - last_pwr_status_toggle > node->state.toggle_power_status)) { + last_pwr_status_toggle = time(nullptr); if (pwr_state & 1) // standby or to-standby exit_standby(node); else
utils/common/media-info.cpp +10 -10
@@ -45,7 +45,7 @@ static struct { { "dvr", MEDIA_TYPE_DVB_DVR }, { "net", MEDIA_TYPE_DVB_NET }, { "ca", MEDIA_TYPE_DTV_CA }, - { NULL, MEDIA_TYPE_UNKNOWN } + { nullptr, MEDIA_TYPE_UNKNOWN } }; media_type mi_media_detect_type(const char *device)
@@ -166,12 +166,12 @@ std::string mi_get_devpath_from_dev_t(dev_t dev) FILE *uevent_fd = fopen(media_uevent_path.c_str(), "r"); - if (uevent_fd == NULL) { + if (uevent_fd == nullptr) { fprintf(stderr, "failed to open %s\n", media_uevent_path.c_str()); return ""; } - char *line = NULL; + char *line = nullptr; size_t size = 0; std::string devpath;
@@ -210,7 +210,7 @@ int mi_get_media_fd(int fd, const char *bus_info) DIR *dp; struct dirent *ep; dp = opendir(media_path.c_str()); - if (dp == NULL) + if (dp == nullptr) return -1; media_path[0] = 0; while ((ep = readdir(dp))) {
@@ -237,7 +237,7 @@ int mi_get_media_fd(int fd, const char *bus_info) static const flag_def entity_flags_def[] = { { MEDIA_ENT_FL_DEFAULT, "default" }, { MEDIA_ENT_FL_CONNECTOR, "connector" }, - { 0, NULL } + { 0, nullptr } }; std::string mi_entflags2s(__u32 flags)
@@ -267,7 +267,7 @@ static const flag_def interface_types_def[] = { { MEDIA_INTF_T_ALSA_HWDEP, "ALSA HWDEP" }, { MEDIA_INTF_T_ALSA_SEQUENCER, "ALSA Sequencer" }, { MEDIA_INTF_T_ALSA_TIMER, "ALSA Timer" }, - { 0, NULL } + { 0, nullptr } }; std::string mi_ifacetype2s(__u32 type)
@@ -314,7 +314,7 @@ static const flag_def entity_functions_def[] = { { MEDIA_ENT_F_PROC_VIDEO_ENCODER, "Video Encoder" }, { MEDIA_ENT_F_VID_MUX, "Video Muxer" }, { MEDIA_ENT_F_VID_IF_BRIDGE, "Video Interface Bridge" }, - { 0, NULL } + { 0, nullptr } }; std::string mi_entfunction2s(__u32 function, bool *is_invalid)
@@ -376,7 +376,7 @@ static const flag_def pad_flags_def[] = { { MEDIA_PAD_FL_SINK, "Sink" }, { MEDIA_PAD_FL_SOURCE, "Source" }, { MEDIA_PAD_FL_MUST_CONNECT, "Must Connect" }, - { 0, NULL } + { 0, nullptr } }; std::string mi_padflags2s(__u32 flags)
@@ -388,7 +388,7 @@ static const flag_def link_flags_def[] = { { MEDIA_LNK_FL_ENABLED, "Enabled" }, { MEDIA_LNK_FL_IMMUTABLE, "Immutable" }, { MEDIA_LNK_FL_DYNAMIC, "Dynamic" }, - { 0, NULL } + { 0, nullptr } }; std::string mi_linkflags2s(__u32 flags)
@@ -512,7 +512,7 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor, __u32 type = link.flags & MEDIA_LNK_FL_LINK_TYPE; __u32 remote_pad; __u32 remote_ent_id = 0; - const media_v2_entity *remote_ent = NULL; + const media_v2_entity *remote_ent = nullptr; if (type != MEDIA_LNK_FL_DATA_LINK || (link.source_id != pad.id && link.sink_id != pad.id))
utils/common/v4l2-info.cpp +19 -19
@@ -190,7 +190,7 @@ static const flag_def bufcap_def[] = { { V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS, "orphaned-bufs" }, { V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF, "m2m-hold-capture-buf" }, { V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS, "mmap-cache-hints" }, - { 0, NULL } + { 0, nullptr } }; std::string bufcap2s(__u32 caps)
@@ -328,7 +328,7 @@ std::string quantization2s(int val) static const flag_def pixflags_def[] = { { V4L2_PIX_FMT_FLAG_PREMUL_ALPHA, "premultiplied-alpha" }, - { 0, NULL } + { 0, nullptr } }; std::string pixflags2s(unsigned flags)
@@ -341,7 +341,7 @@ static const flag_def service_def[] = { { V4L2_SLICED_VPS, "vps" }, { V4L2_SLICED_CAPTION_525, "cc" }, { V4L2_SLICED_WSS_625, "wss" }, - { 0, NULL } + { 0, nullptr } }; std::string service2s(unsigned service)
@@ -401,7 +401,7 @@ static const flag_def selection_targets_def[] = { { V4L2_SEL_TGT_COMPOSE_BOUNDS, "compose_bounds" }, { V4L2_SEL_TGT_COMPOSE_PADDED, "compose_padded" }, { V4L2_SEL_TGT_NATIVE_SIZE, "native_size" }, - { 0, NULL } + { 0, nullptr } }; bool valid_seltarget_at_idx(unsigned i)
@@ -420,7 +420,7 @@ std::string seltarget2s(__u32 target) { int i = 0; - while (selection_targets_def[i].str != NULL) { + while (selection_targets_def[i].str != nullptr) { if (selection_targets_def[i].flag == target) return selection_targets_def[i].str; i++;
@@ -432,7 +432,7 @@ const flag_def selection_flags_def[] = { { V4L2_SEL_FLAG_GE, "ge" }, { V4L2_SEL_FLAG_LE, "le" }, { V4L2_SEL_FLAG_KEEP_CONFIG, "keep-config" }, - { 0, NULL } + { 0, nullptr } }; std::string selflags2s(__u32 flags)
@@ -443,19 +443,19 @@ std::string selflags2s(__u32 flags) static const char *std_pal[] = { "B", "B1", "G", "H", "I", "D", "D1", "K", "M", "N", "Nc", "60", - NULL + nullptr }; static const char *std_ntsc[] = { "M", "M-JP", "443", "M-KR", - NULL + nullptr }; static const char *std_secam[] = { "B", "D", "G", "H", "K", "K1", "L", "Lc", - NULL + nullptr }; static const char *std_atsc[] = { "8-VSB", "16-VSB", - NULL + nullptr }; static std::string partstd2s(const char *prefix, const char *stds[], unsigned long long std)
@@ -512,7 +512,7 @@ std::string ctrlflags2s(__u32 flags) { V4L2_CTRL_FLAG_HAS_PAYLOAD,"has-payload" }, { V4L2_CTRL_FLAG_EXECUTE_ON_WRITE, "execute-on-write" }, { V4L2_CTRL_FLAG_MODIFY_LAYOUT, "modify-layout" }, - { 0, NULL } + { 0, nullptr } }; return flags2s(flags, def); }
@@ -533,7 +533,7 @@ static const flag_def in_status_def[] = { { V4L2_IN_ST_MACROVISION, "macrovision" }, { V4L2_IN_ST_NO_ACCESS, "no conditional access" }, { V4L2_IN_ST_VTR, "VTR time constant" }, - { 0, NULL } + { 0, nullptr } }; std::string in_status2s(__u32 status)
@@ -545,7 +545,7 @@ static const flag_def input_cap_def[] = { { V4L2_IN_CAP_DV_TIMINGS, "DV timings" }, { V4L2_IN_CAP_STD, "SDTV standards" }, { V4L2_IN_CAP_NATIVE_SIZE, "Native Size" }, - { 0, NULL } + { 0, nullptr } }; std::string input_cap2s(__u32 capabilities)
@@ -557,7 +557,7 @@ static const flag_def output_cap_def[] = { { V4L2_OUT_CAP_DV_TIMINGS, "DV timings" }, { V4L2_OUT_CAP_STD, "SDTV standards" }, { V4L2_OUT_CAP_NATIVE_SIZE, "Native Size" }, - { 0, NULL } + { 0, nullptr } }; std::string output_cap2s(__u32 capabilities)
@@ -617,7 +617,7 @@ static const flag_def dv_standards_def[] = { { V4L2_DV_BT_STD_CVT, "CVT" }, { V4L2_DV_BT_STD_GTF, "GTF" }, { V4L2_DV_BT_STD_SDI, "SDI" }, - { 0, NULL } + { 0, nullptr } }; std::string dv_standards2s(__u32 flags)
@@ -661,7 +661,7 @@ static const flag_def dv_caps_def[] = { { V4L2_DV_BT_CAP_PROGRESSIVE, "Progressive" }, { V4L2_DV_BT_CAP_REDUCED_BLANKING, "Reduced Blanking" }, { V4L2_DV_BT_CAP_CUSTOM, "Custom Formats" }, - { 0, NULL } + { 0, nullptr } }; std::string dv_caps2s(__u32 flags)
@@ -675,7 +675,7 @@ static const flag_def tc_flags_def[] = { { V4L2_TC_USERBITS_field, "userbits-field" }, { V4L2_TC_USERBITS_USERDEFINED, "userbits-userdefined" }, { V4L2_TC_USERBITS_8BITCHARS, "userbits-8bitchars" }, - { 0, NULL } + { 0, nullptr } }; std::string tc_flags2s(__u32 flags)
@@ -699,7 +699,7 @@ static const flag_def buffer_flags_def[] = { { V4L2_BUF_FLAG_LAST, "last" }, { V4L2_BUF_FLAG_REQUEST_FD, "request-fd" }, { V4L2_BUF_FLAG_IN_REQUEST, "in-request" }, - { 0, NULL } + { 0, nullptr } }; std::string bufferflags2s(__u32 flags)
@@ -741,7 +741,7 @@ std::string bufferflags2s(__u32 flags) static const flag_def vbi_def[] = { { V4L2_VBI_UNSYNC, "unsynchronized" }, { V4L2_VBI_INTERLACED, "interlaced" }, - { 0, NULL } + { 0, nullptr } }; std::string vbiflags2s(__u32 flags)
utils/libcecutil/cec-info.cpp +4 -4
@@ -23,7 +23,7 @@ const char *cec_opcode2s(unsigned opcode) for (auto i : msgtable) if (i.opcode == opcode) return i.name; - return NULL; + return nullptr; } const char *cec_cdc_opcode2s(unsigned cdc_opcode)
@@ -31,7 +31,7 @@ const char *cec_cdc_opcode2s(unsigned cdc_opcode) for (auto i : cdcmsgtable) if (i.opcode == cdc_opcode) return i.name; - return NULL; + return nullptr; } const char *cec_htng_opcode2s(unsigned htng_opcode)
@@ -39,7 +39,7 @@ const char *cec_htng_opcode2s(unsigned htng_opcode) for (auto i : htngmsgtable) if (i.opcode == htng_opcode) return i.name; - return NULL; + return nullptr; } static std::string caps2s(unsigned caps)
@@ -493,7 +493,7 @@ std::string cec_device_find(const char *driver, const char *adapter) std::string name; dp = opendir("/dev"); - if (dp == NULL) { + if (dp == nullptr) { perror("Couldn't open the directory"); return name; }
utils/libcecutil/cec-log.cpp +2 -2
@@ -114,7 +114,7 @@ static void log_htng_unknown_msg(const struct cec_msg *msg); const struct cec_msg_args *cec_log_msg_args(unsigned int index) { if (index >= sizeof(messages) / sizeof(messages[0])) - return NULL; + return nullptr; return &messages[index]; }
@@ -325,5 +325,5 @@ const char *cec_log_ui_cmd_string(__u8 ui_cmd) if (type_ui_cmd[i].value == ui_cmd) return type_ui_cmd[i].type_name; } - return NULL; + return nullptr; }
utils/libcecutil/cec-parse.cpp +3 -3
@@ -153,7 +153,7 @@ int cec_parse_subopt(char **subs, const char * const *subopts, char **value) fprintf(stderr, "Invalid suboptions specified\n"); return -1; } - if (*value == NULL) { + if (*value == nullptr) { fprintf(stderr, "No value given to suboption <%s>\n", subopts[opt]); return -1;
@@ -164,7 +164,7 @@ int cec_parse_subopt(char **subs, const char * const *subopts, char **value) static unsigned parse_enum(const char *value, const struct cec_arg *a) { if (isdigit(*value)) - return strtoul(value, NULL, 0); + return strtoul(value, nullptr, 0); for (int i = 0; i < a->num_enum_values; i++) { if (!strcmp(value, a->values[i].type_name)) return a->values[i].value;
@@ -177,7 +177,7 @@ unsigned cec_parse_phys_addr(const char *value) unsigned p1, p2, p3, p4; if (!std::strchr(value, '.')) - return strtoul(value, NULL, 0); + return strtoul(value, nullptr, 0); if (sscanf(value, "%x.%x.%x.%x", &p1, &p2, &p3, &p4) != 4) { fprintf(stderr, "Expected a physical address of the form x.x.x.x\n"); return 0;
utils/rds-ctl/rds-ctl.cpp +29 -29
108 lines not on this page · raw message
utils/v4l2-compliance/v4l2-compliance.cpp +39 -39
149 lines not on this page · raw message
utils/v4l2-compliance/v4l2-test-buffers.cpp +29 -29
175 lines not on this page · raw message
utils/v4l2-compliance/v4l2-test-colors.cpp +1 -1
@@ -476,7 +476,7 @@ static int testColorsFmt(struct node *node, unsigned component, { cv4l_queue q; cv4l_fmt fmt; - __u8 *planes[3] = { 0, 0, 0 }; + __u8 *planes[3] = { nullptr, nullptr, nullptr }; skip++; node->g_fmt(fmt);
utils/v4l2-compliance/v4l2-test-controls.cpp +3 -3
@@ -616,7 +616,7 @@ int testExtendedControls(struct node *node) info("checking extended control '%s' (0x%08x)\n", qctrl.name, qctrl.id); ctrl.id = qctrl.id; ctrl.size = 0; - ctrl.ptr = NULL; + ctrl.ptr = nullptr; ctrl.reserved2[0] = 0; ctrls.count = 1;
@@ -690,7 +690,7 @@ int testExtendedControls(struct node *node) } if (qctrl.type == V4L2_CTRL_TYPE_STRING) delete [] ctrl.string; - ctrl.string = NULL; + ctrl.string = nullptr; } ctrls.which = 0;
@@ -824,7 +824,7 @@ int testEvents(struct node *node) //if (qctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS) FD_ZERO(&set); FD_SET(node->g_fd(), &set); - ret = select(node->g_fd() + 1, NULL, NULL, &set, &timeout); + ret = select(node->g_fd() + 1, nullptr, nullptr, &set, &timeout); if (ret == 0) { if (qctrl.type != V4L2_CTRL_TYPE_CTRL_CLASS) return fail("failed to find event for control '%s'\n", qctrl.name);
utils/v4l2-compliance/v4l2-test-debug.cpp +1 -1
@@ -57,5 +57,5 @@ int testRegister(struct node *node) int testLogStatus(struct node *node) { - return doioctl(node, VIDIOC_LOG_STATUS, NULL); + return doioctl(node, VIDIOC_LOG_STATUS, nullptr); }
utils/v4l2-compliance/v4l2-test-formats.cpp +2 -2
@@ -414,7 +414,7 @@ static void createInvalidFmt(struct v4l2_format &fmt, struct v4l2_clip &clip, un clip.next = (struct v4l2_clip *)0x0eadbeef; fmt.fmt.win.clipcount = 1; fmt.fmt.win.clips = &clip; - fmt.fmt.win.bitmap = NULL; + fmt.fmt.win.bitmap = nullptr; } }
@@ -1177,7 +1177,7 @@ int testSetFormats(struct node *node) // Test if setting a format on one fh will set the format for all // filehandles. - if (node->node2 == NULL) + if (node->node2 == nullptr) return 0; // m2m devices are special in that the format is often per-filehandle.
utils/v4l2-compliance/v4l2-test-io-config.cpp +1 -1
@@ -579,7 +579,7 @@ static int checkEdid(struct node *node, unsigned pad, bool is_input) } edid.blocks = blocks; edid.pad = pad; - edid.edid = NULL; + edid.edid = nullptr; ret = doioctl(node, VIDIOC_S_EDID, &edid); fail_on_test(ret != EFAULT); edid.edid = (__u8 *)0x0eadbeef;
utils/v4l2-compliance/v4l2-test-media.cpp +4 -4
@@ -32,7 +32,7 @@ int testMediaDeviceInfo(struct node *node) struct media_device_info mdinfo; memset(&mdinfo, 0xff, sizeof(mdinfo)); - fail_on_test(doioctl(node, MEDIA_IOC_DEVICE_INFO, NULL) != EFAULT); + fail_on_test(doioctl(node, MEDIA_IOC_DEVICE_INFO, nullptr) != EFAULT); fail_on_test(doioctl(node, MEDIA_IOC_DEVICE_INFO, &mdinfo)); fail_on_test(check_0(mdinfo.reserved, sizeof(mdinfo.reserved))); fail_on_test(check_string(mdinfo.driver, sizeof(mdinfo.driver)));
@@ -66,7 +66,7 @@ static int checkDevice(__u32 major, __u32 minor, bool iface, __u32 id) fail_on_test(snprintf(dev_path, sizeof(dev_path), "/sys/dev/char/%d:%d", major, minor) == -1); DIR *dp = opendir(dev_path); - if (dp == NULL) + if (dp == nullptr) return fail("couldn't find %s for %s %u\n", dev_path, iface ? "interface" : "entity", id); closedir(dp);
@@ -396,10 +396,10 @@ int testMediaEnum(struct node *node) fail_on_test(links.links); links.pads = (struct media_pad_desc *)4; fail_on_test(ent.pads && doioctl(node, MEDIA_IOC_ENUM_LINKS, &links) != EFAULT); - links.pads = NULL; + links.pads = nullptr; links.links = (struct media_link_desc *)4; fail_on_test(ent.links && doioctl(node, MEDIA_IOC_ENUM_LINKS, &links) != EFAULT); - links.links = NULL; + links.links = nullptr; links.pads = new media_pad_desc[ent.pads]; memset(links.pads, 0xff, ent.pads * sizeof(*links.pads)); links.links = new media_link_desc[ent.links];
utils/v4l2-ctl/v4l2-ctl-common.cpp +15 -15
@@ -123,7 +123,7 @@ static const char *prefixes[] = { "v4l-subdev", "v4l-touch", "media", - NULL + nullptr }; static bool is_v4l_dev(const char *name)
@@ -173,7 +173,7 @@ static void list_media_devices(const std::string &media_bus_info) std::map<dev_t, std::string> devices; dp = opendir("/dev"); - if (dp == NULL) { + if (dp == nullptr) { perror ("Couldn't open the directory"); return; }
@@ -239,7 +239,7 @@ static void list_devices() struct v4l2_capability vcap; dp = opendir("/dev"); - if (dp == NULL) { + if (dp == nullptr) { perror ("Couldn't open the directory"); return; }
@@ -520,7 +520,7 @@ static int print_control(int fd, struct v4l2_query_ext_ctrl &qctrl, int show_men return 1; } if (qctrl.type >= V4L2_CTRL_COMPOUND_TYPES) { - print_qctrl(fd, &qctrl, NULL, show_menus); + print_qctrl(fd, &qctrl, nullptr, show_menus); return 1; } ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id);
@@ -745,9 +745,9 @@ static bool parse_subset(char *optarg) return true; } if (idx & 1) - subset.offset[idx / 2] = strtoul(optarg, 0, 0); + subset.offset[idx / 2] = strtoul(optarg, nullptr, 0); else { - subset.size[idx / 2 - 1] = strtoul(optarg, 0, 0); + subset.size[idx / 2 - 1] = strtoul(optarg, nullptr, 0); if (subset.size[idx / 2 - 1] == 0) { fprintf(stderr, "<size> cannot be 0\n"); return true;
@@ -755,7 +755,7 @@ static bool parse_subset(char *optarg) } } idx++; - if (p == NULL) + if (p == nullptr) break; optarg = p + 1; }
@@ -775,7 +775,7 @@ static bool parse_subset(char *optarg) static bool parse_next_subopt(char **subs, char **value) { static char *const subopts[] = { - NULL + nullptr }; int opt = getsubopt(subs, subopts, value);
@@ -829,7 +829,7 @@ void common_cmd(const std::string &media_bus_info, int ch, char *optarg) } break; case OptSetPriority: - prio = static_cast<enum v4l2_priority>(strtoul(optarg, 0L, 0)); + prio = static_cast<enum v4l2_priority>(strtoul(optarg, nullptr, 0)); break; case OptListDevices: if (media_bus_info.empty())
@@ -940,19 +940,19 @@ void common_set(cv4l_fd &_fd) switch (qc.type) { case V4L2_CTRL_TYPE_U8: - v = strtoul(set_ctrl.second.c_str(), NULL, 0); + v = strtoul(set_ctrl.second.c_str(), nullptr, 0); for (i = 0; i < qc.elems; i++) if (idx_in_subset(qc, subset, divide, i)) ctrl.p_u8[i] = v; break; case V4L2_CTRL_TYPE_U16: - v = strtoul(set_ctrl.second.c_str(), NULL, 0); + v = strtoul(set_ctrl.second.c_str(), nullptr, 0); for (i = 0; i < qc.elems; i++) if (idx_in_subset(qc, subset, divide, i)) ctrl.p_u16[i] = v; break; case V4L2_CTRL_TYPE_U32: - v = strtoul(set_ctrl.second.c_str(), NULL, 0); + v = strtoul(set_ctrl.second.c_str(), nullptr, 0); for (i = 0; i < qc.elems; i++) if (idx_in_subset(qc, subset, divide, i)) ctrl.p_u32[i] = v;
@@ -974,9 +974,9 @@ void common_set(cv4l_fd &_fd) if (V4L2_CTRL_DRIVER_PRIV(ctrl.id)) use_ext_ctrls = true; if (qc.type == V4L2_CTRL_TYPE_INTEGER64) - ctrl.value64 = strtoll(set_ctrl.second.c_str(), NULL, 0); + ctrl.value64 = strtoll(set_ctrl.second.c_str(), nullptr, 0); else - ctrl.value = strtol(set_ctrl.second.c_str(), NULL, 0); + ctrl.value = strtol(set_ctrl.second.c_str(), nullptr, 0); } class2ctrls[V4L2_CTRL_ID2WHICH(ctrl.id)].push_back(ctrl); }
@@ -1178,7 +1178,7 @@ void common_get(cv4l_fd &_fd) static char buf[40960]; int len = -1; - if (doioctl(fd, VIDIOC_LOG_STATUS, NULL) == 0) { + if (doioctl(fd, VIDIOC_LOG_STATUS, nullptr) == 0) { printf("\nStatus Log:\n\n"); #ifdef HAVE_KLOGCTL len = klogctl(3, buf, sizeof(buf) - 1);
utils/v4l2-ctl/v4l2-ctl-edid.cpp +20 -20
@@ -225,7 +225,7 @@ static void edid_add_block(struct v4l2_edid *e) if (e->blocks > 256) { fprintf(stderr, "edid file error: too long\n"); free(e->edid); - e->edid = NULL; + e->edid = nullptr; std::exit(EXIT_FAILURE); } e->edid = static_cast<unsigned char *>(realloc(e->edid, e->blocks * 128));
@@ -238,7 +238,7 @@ static void read_edid_file(FILE *f, struct v4l2_edid *e) int c; fseek(f, SEEK_SET, 0); - e->edid = NULL; + e->edid = nullptr; e->blocks = 0; while ((c = fgetc(f)) != EOF) {
@@ -258,7 +258,7 @@ static void read_edid_file(FILE *f, struct v4l2_edid *e) value[1] = c; if (i % 256 == 1) edid_add_block(e); - e->edid[i / 2] = strtoul(value, 0, 16); + e->edid[i / 2] = strtoul(value, nullptr, 16); } else { value[0] = c; }
@@ -704,7 +704,7 @@ static unsigned short parse_phys_addr(const char *value) unsigned p1, p2, p3, p4; if (!std::strchr(value, '.')) - return strtoul(value, NULL, 0); + return strtoul(value, nullptr, 0); if (sscanf(value, "%x.%x.%x.%x", &p1, &p2, &p3, &p4) != 4) { fprintf(stderr, "Expected a physical address of the form x.x.x.x\n"); return 0xffff;
@@ -908,7 +908,7 @@ void edid_cmd(int ch, char *optarg) switch (ch) { case OptSetEdid: memset(&sedid, 0, sizeof(sedid)); - file_in = NULL; + file_in = nullptr; if (!optarg) break; subs = optarg;
@@ -971,7 +971,7 @@ void edid_cmd(int ch, char *optarg) "btfc", "btfl-btbr", "tpls-tprs", - NULL + nullptr }; int opt = getsubopt(&subs, (char* const*)subopts, &value);
@@ -981,7 +981,7 @@ void edid_cmd(int ch, char *optarg) edid_usage(); std::exit(EXIT_FAILURE); } - if (value == NULL && opt <= 8) { + if (value == nullptr && opt <= 8) { fprintf(stderr, "No value given to suboption <%s>\n", subopts[opt]); edid_usage();
@@ -989,7 +989,7 @@ void edid_cmd(int ch, char *optarg) } switch (opt) { case 0: - sedid.pad = strtoul(value, 0, 0); + sedid.pad = strtoul(value, nullptr, 0); break; case 1: case 2: /* keep edid for compat reasons, it's the same as type */
@@ -1044,13 +1044,13 @@ void edid_cmd(int ch, char *optarg) phys_addr = parse_phys_addr(value); break; case 6: - mod_s_pt = strtoul(value, 0, 0) & 3; + mod_s_pt = strtoul(value, nullptr, 0) & 3; break; case 7: - mod_s_it = strtoul(value, 0, 0) & 3; + mod_s_it = strtoul(value, nullptr, 0) & 3; break; case 8: - mod_s_ce = strtoul(value, 0, 0) & 3; + mod_s_ce = strtoul(value, nullptr, 0) & 3; break; case 9: toggle_hdmi_vsdb_dc_flags |= HDMI_VSDB_Y444_BIT; break; case 10: toggle_hdmi_vsdb_dc_flags |= HDMI_VSDB_30_BIT; break;
@@ -1109,14 +1109,14 @@ void edid_cmd(int ch, char *optarg) case OptClearEdid: if (optarg) - clear_pad = strtoul(optarg, 0, 0); + clear_pad = strtoul(optarg, nullptr, 0); break; case OptGetEdid: memset(&gedid, 0, sizeof(gedid)); gedid.blocks = 256; /* default all blocks */ gformat = HEX; /* default hex output */ - file_out = NULL; + file_out = nullptr; if (!optarg) break; subs = optarg;
@@ -1127,22 +1127,22 @@ void edid_cmd(int ch, char *optarg) "blocks", "format", "file", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) { case 0: - gedid.pad = strtoul(value, 0, 0); + gedid.pad = strtoul(value, nullptr, 0); break; case 1: - gedid.start_block = strtoul(value, 0, 0); + gedid.start_block = strtoul(value, nullptr, 0); if (gedid.start_block > 255) { fprintf(stderr, "startblock %d too large, max 255\n", gedid.start_block); std::exit(EXIT_FAILURE); } break; case 2: - gedid.blocks = strtoul(value, 0, 0); + gedid.blocks = strtoul(value, nullptr, 0); break; case 3: if (!strcmp(value, "hex")) {
@@ -1172,7 +1172,7 @@ void edid_cmd(int ch, char *optarg) case OptInfoEdid: memset(&info_edid, 0, sizeof(info_edid)); if (optarg) - info_edid.pad = strtoul(optarg, 0, 0); + info_edid.pad = strtoul(optarg, nullptr, 0); break; } }
@@ -1191,7 +1191,7 @@ void edid_set(cv4l_fd &_fd) } if (options[OptSetEdid]) { - FILE *fin = NULL; + FILE *fin = nullptr; bool must_fix_edid = options[OptFixEdidChecksums]; if (file_in) {
@@ -1299,7 +1299,7 @@ void edid_set(cv4l_fd &_fd) if (fin) { if (sedid.edid) { free(sedid.edid); - sedid.edid = NULL; + sedid.edid = nullptr; } if (fin != stdin) fclose(fin);
utils/v4l2-ctl/v4l2-ctl-io.cpp +4 -4
@@ -63,16 +63,16 @@ void io_cmd(int ch, char *optarg) { switch (ch) { case OptSetInput: - input = strtol(optarg, 0L, 0); + input = strtol(optarg, nullptr, 0); break; case OptSetOutput: - output = strtol(optarg, 0L, 0); + output = strtol(optarg, nullptr, 0); break; case OptSetAudioInput: - vaudio.index = strtol(optarg, 0L, 0); + vaudio.index = strtol(optarg, nullptr, 0); break; case OptSetAudioOutput: - vaudout.index = strtol(optarg, 0L, 0); + vaudout.index = strtol(optarg, nullptr, 0); break; } }
utils/v4l2-ctl/v4l2-ctl-meta.cpp +3 -3
@@ -48,16 +48,16 @@ void meta_cmd(int ch, char *optarg) vfmt.fmt.meta.dataformat = v4l2_fourcc(optarg[0], optarg[1], optarg[2], optarg[3]); } else { - vfmt.fmt.meta.dataformat = strtol(optarg, 0L, 0); + vfmt.fmt.meta.dataformat = strtol(optarg, nullptr, 0); } break; case OptListMetaFormats: if (optarg) - mbus_code = strtoul(optarg, 0L, 0); + mbus_code = strtoul(optarg, nullptr, 0); break; case OptListMetaOutFormats: if (optarg) - mbus_code_out = strtoul(optarg, 0L, 0); + mbus_code_out = strtoul(optarg, nullptr, 0); break; } }
utils/v4l2-ctl/v4l2-ctl-misc.cpp +8 -8
@@ -170,10 +170,10 @@ void misc_cmd(int ch, char *optarg) switch (ch) { case OptSetParm: - fps = strtod(optarg, NULL); + fps = strtod(optarg, nullptr); break; case OptSetOutputParm: - output_fps = strtod(optarg, NULL); + output_fps = strtod(optarg, nullptr); break; case OptSetJpegComp: subs = optarg;
@@ -186,14 +186,14 @@ void misc_cmd(int ch, char *optarg) "quality", "markers", "comment", - NULL + nullptr }; size_t len; int opt = parse_subopt(&subs, subopts, &value); switch (opt) { case 16: - jpegcomp.quality = strtol(value, 0L, 0); + jpegcomp.quality = strtol(value, nullptr, 0); break; case 17: if (strstr(value, "dht"))
@@ -238,7 +238,7 @@ void misc_cmd(int ch, char *optarg) static const char *const subopts[] = { "cmd", "flags", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) {
@@ -264,7 +264,7 @@ void misc_cmd(int ch, char *optarg) "stop_pts", "start_speed", "start_format", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) {
@@ -275,10 +275,10 @@ void misc_cmd(int ch, char *optarg) dec_cmd.flags = parse_decflags(value); break; case 2: - dec_cmd.stop.pts = strtoull(value, 0, 0); + dec_cmd.stop.pts = strtoull(value, nullptr, 0); break; case 3: - dec_cmd.start.speed = strtol(value, 0, 0); + dec_cmd.start.speed = strtol(value, nullptr, 0); break; case 4: if (!strcmp(value, "gop"))
utils/v4l2-ctl/v4l2-ctl-overlay.cpp +26 -26
163 lines not on this page · raw message
utils/v4l2-ctl/v4l2-ctl-sdr.cpp +1 -1
@@ -41,7 +41,7 @@ void sdr_cmd(int ch, char *optarg) vfmt.fmt.sdr.pixelformat = v4l2_fourcc(optarg[0], optarg[1], optarg[2], optarg[3]); } else { - vfmt.fmt.sdr.pixelformat = strtol(optarg, 0L, 0); + vfmt.fmt.sdr.pixelformat = strtol(optarg, nullptr, 0); } break; }
utils/v4l2-ctl/v4l2-ctl-selection.cpp +10 -10
@@ -98,24 +98,24 @@ static void parse_crop(char *optarg, unsigned int &set_crop, v4l2_rect &vcrop) "top", "width", "height", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) { case 0: - vcrop.left = strtol(value, 0L, 0); + vcrop.left = strtol(value, nullptr, 0); set_crop |= CropLeft; break; case 1: - vcrop.top = strtol(value, 0L, 0); + vcrop.top = strtol(value, nullptr, 0); set_crop |= CropTop; break; case 2: - vcrop.width = strtol(value, 0L, 0); + vcrop.width = strtol(value, nullptr, 0); set_crop |= CropWidth; break; case 3: - vcrop.height = strtol(value, 0L, 0); + vcrop.height = strtol(value, nullptr, 0); set_crop |= CropHeight; break; default:
@@ -160,7 +160,7 @@ static int parse_selection(char *optarg, unsigned int &set_sel, v4l2_selection & "top", "width", "height", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) {
@@ -176,19 +176,19 @@ static int parse_selection(char *optarg, unsigned int &set_sel, v4l2_selection & set_sel |= SelectionFlags; break; case 2: - vsel.r.left = strtol(value, 0L, 0); + vsel.r.left = strtol(value, nullptr, 0); set_sel |= SelectionLeft; break; case 3: - vsel.r.top = strtol(value, 0L, 0); + vsel.r.top = strtol(value, nullptr, 0); set_sel |= SelectionTop; break; case 4: - vsel.r.width = strtoul(value, 0L, 0); + vsel.r.width = strtoul(value, nullptr, 0); set_sel |= SelectionWidth; break; case 5: - vsel.r.height = strtoul(value, 0L, 0); + vsel.r.height = strtoul(value, nullptr, 0); set_sel |= SelectionHeight; break; default:
utils/v4l2-ctl/v4l2-ctl-stds.cpp +6 -6
@@ -182,7 +182,7 @@ static int parse_timing_subopt(char **subopt_str, int *value) "reduced-blanking", "reduced-fps", "clear", - NULL + nullptr }; opt = getsubopt(subopt_str, (char* const*) subopt_list, &opt_str);
@@ -192,7 +192,7 @@ static int parse_timing_subopt(char **subopt_str, int *value) stds_usage(); std::exit(EXIT_FAILURE); } - if (opt_str == NULL && opt != CVT && opt != GTF && opt != CLEAR) { + if (opt_str == nullptr && opt != CVT && opt != GTF && opt != CLEAR) { fprintf(stderr, "No value given to suboption <%s>\n", subopt_list[opt]); stds_usage();
@@ -200,7 +200,7 @@ static int parse_timing_subopt(char **subopt_str, int *value) } if (opt_str) - *value = strtol(opt_str, 0L, 0); + *value = strtol(opt_str, nullptr, 0); return opt; }
@@ -446,7 +446,7 @@ void stds_cmd(int ch, char *optarg) standard = V4L2_STD_SECAM; } else if (isdigit(optarg[0])) { - standard = strtol(optarg, 0L, 0) | (1ULL << 63); + standard = strtol(optarg, nullptr, 0) | (1ULL << 63); } else { fprintf(stderr, "Unknown standard '%s'\n", optarg); stds_usage();
@@ -458,11 +458,11 @@ void stds_cmd(int ch, char *optarg) break; case OptListDvTimings: if (optarg) - list_dv_timings_pad = strtoul(optarg, 0L, 0); + list_dv_timings_pad = strtoul(optarg, nullptr, 0); break; case OptGetDvTimingsCap: if (optarg) - dv_timings_cap_pad = strtoul(optarg, 0L, 0); + dv_timings_cap_pad = strtoul(optarg, nullptr, 0); break; } }
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +36 -36
268 lines not on this page · raw message
utils/v4l2-ctl/v4l2-ctl-subdev.cpp +28 -28
177 lines not on this page · raw message
utils/v4l2-ctl/v4l2-ctl-tuner.cpp +9 -9
@@ -163,24 +163,24 @@ static void parse_freq_seek(char *optarg, struct v4l2_hw_freq_seek &seek) "spacing", "low", "high", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) { case 0: - seek.seek_upward = strtol(value, 0L, 0); + seek.seek_upward = strtol(value, nullptr, 0); break; case 1: - seek.wrap_around = strtol(value, 0L, 0); + seek.wrap_around = strtol(value, nullptr, 0); break; case 2: - seek.spacing = strtol(value, 0L, 0); + seek.spacing = strtol(value, nullptr, 0); break; case 3: - low = strtod(value, NULL); + low = strtod(value, nullptr); break; case 4: - high = strtod(value, NULL); + high = strtod(value, nullptr); break; default: tuner_usage();
@@ -193,7 +193,7 @@ void tuner_cmd(int ch, char *optarg) { switch (ch) { case OptSetFreq: - freq = strtod(optarg, NULL); + freq = strtod(optarg, nullptr); break; case OptSetTuner: if (!strcmp(optarg, "stereo"))
@@ -213,7 +213,7 @@ void tuner_cmd(int ch, char *optarg) } break; case OptSetModulator: - txsubchans = strtol(optarg, 0L, 0); + txsubchans = strtol(optarg, nullptr, 0); if (!strcmp(optarg, "stereo")) txsubchans = V4L2_TUNER_SUB_STEREO; else if (!strcmp(optarg, "stereo-sap"))
@@ -238,7 +238,7 @@ void tuner_cmd(int ch, char *optarg) parse_freq_seek(optarg, freq_seek); break; case OptTunerIndex: - tuner_index = strtoul(optarg, NULL, 0); + tuner_index = strtoul(optarg, nullptr, 0); break; } }
utils/v4l2-ctl/v4l2-ctl-vbi.cpp +9 -9
@@ -104,7 +104,7 @@ void vbi_cmd(int ch, char *optarg) V4L2_SLICED_VPS; else vbi_usage(); - if (subs == NULL) + if (subs == nullptr) break; optarg = subs + 1; }
@@ -131,30 +131,30 @@ void vbi_cmd(int ch, char *optarg) "start1", "count0", "count1", - NULL + nullptr }; switch (parse_subopt(&subs, subopts, &value)) { case 0: - raw->fmt.vbi.sampling_rate = strtoul(value, NULL, 0); + raw->fmt.vbi.sampling_rate = strtoul(value, nullptr, 0); break; case 1: - raw->fmt.vbi.offset = strtoul(value, NULL, 0); + raw->fmt.vbi.offset = strtoul(value, nullptr, 0); break; case 2: - raw->fmt.vbi.samples_per_line = strtoul(value, NULL, 0); + raw->fmt.vbi.samples_per_line = strtoul(value, nullptr, 0); break; case 3: - raw->fmt.vbi.start[0] = strtoul(value, NULL, 0); + raw->fmt.vbi.start[0] = strtoul(value, nullptr, 0); break; case 4: - raw->fmt.vbi.start[1] = strtoul(value, NULL, 0); + raw->fmt.vbi.start[1] = strtoul(value, nullptr, 0); break; case 5: - raw->fmt.vbi.count[0] = strtoul(value, NULL, 0); + raw->fmt.vbi.count[0] = strtoul(value, nullptr, 0); break; case 6: - raw->fmt.vbi.count[1] = strtoul(value, NULL, 0); + raw->fmt.vbi.count[1] = strtoul(value, nullptr, 0); break; default: vbi_usage();
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +6 -6
@@ -114,7 +114,7 @@ void vidcap_cmd(int ch, char *optarg) case OptListFormats: case OptListFormatsExt:
Lines of this file are not shown. View the raw message.
utils/v4l2-ctl/v4l2-ctl.cpp +234 -234
468 lines not on this page · raw message
utils/v4l2-dbg/v4l2-dbg.cpp +29 -29
58 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
PATCH 2/2 clang-tidy: add a bunch of const
Found with cppcoreguidelines-interfaces-global-init
Signed-off-by Rosen Penev <[email protected]>
--- lib/libv4lconvert/processing/autogain.c | 2 +- lib/libv4lconvert/processing/gamma.c | 2 +- lib/libv4lconvert/processing/libv4lprocessing-priv.h | 6 +++--- lib/libv4lconvert/processing/libv4lprocessing.c | 2 +- lib/libv4lconvert/processing/whitebalance.c | 2 +- utils/cec-compliance/cec-test.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
lib/libv4lconvert/processing/autogain.c +1 -1
@@ -213,6 +213,6 @@ static int autogain_calculate_lookup_tables(return 0 ; } -struct v4lprocessing_filter autogain_filter = { +const struct v4lprocessing_filter autogain_filter = { autogain_active, autogain_calculate_lookup_tables };
lib/libv4lconvert/processing/gamma.c +1 -1
@@ -57,6 +57,6 @@ static int gamma_calculate_lookup_tables(return 1 ; } -struct v4lprocessing_filter gamma_filter = { +const struct v4lprocessing_filter gamma_filter = { gamma_active, gamma_calculate_lookup_tables };
lib/libv4lconvert/processing/libv4lprocessing-priv.h +3 -3
@@ -61,8 +61,8 @@ struct v4lprocessing_filter { unsigned char *buf, const struct v4l2_format *fmt); }; -extern struct v4lprocessing_filter whitebalance_filter; -extern struct v4lprocessing_filter autogain_filter; -extern struct v4lprocessing_filter gamma_filter; +extern const struct v4lprocessing_filter whitebalance_filter; +extern const struct v4lprocessing_filter autogain_filter; +extern const struct v4lprocessing_filter gamma_filter;#endif
lib/libv4lconvert/processing/libv4lprocessing.c +1 -1
@@ -27,7 +27,7 @@#include "libv4lprocessing-priv.h" #include "../libv4lconvert-priv.h" /* for PIX_FMT defines */ -static struct v4lprocessing_filter *filters[] = { +static const struct v4lprocessing_filter *filters[] = { &whitebalance_filter, &autogain_filter, &gamma_filter,
lib/libv4lconvert/processing/whitebalance.c +1 -1
@@ -205,6 +205,6 @@ static int whitebalance_calculate_lookup_tables(return 0 ;/* Should never happen */ } -struct v4lprocessing_filter whitebalance_filter = { +const struct v4lprocessing_filter whitebalance_filter = { whitebalance_active, whitebalance_calculate_lookup_tables };
utils/cec-compliance/cec-test.cpp +1 -1
@@ -1414,7 +1414,7 @@ static struct remote_subtest post_test_subtests[] = { }; -static struct remote_test tests[] = { +static const struct remote_test tests[] = { test_case("Core", TAG_CORE, core_subtests),
Signature · 1 line
2.26.2