aboutsummaryrefslogtreecommitdiffstats
path: root/utils/cec-follower
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-10-03 15:44:34 -0700
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-10-30 16:12:42 +0100
commit8755686268de6dc3dbbba865ec1384efb347ce95 (patch)
tree0c9cc25cbbeb5986547b5891dad7e1c923c7552c /utils/cec-follower
parent7ab86eba54233fa31344501134b1c1ab7f10c535 (diff)
clang-tidy: use nullptr
Found with modernize-use-nullptr Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/cec-follower')
-rw-r--r--utils/cec-follower/cec-follower.cpp44
-rw-r--r--utils/cec-follower/cec-processing.cpp16
2 files changed, 30 insertions, 30 deletions
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index 91f36bfd..bb63f90d 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -49,23 +49,23 @@ bool show_warnings = true;
unsigned warnings;
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 },
- { "trace", no_argument, 0, OptTrace },
- { "verbose", no_argument, 0, OptVerbose },
- { "show-msgs", no_argument, 0, OptShowMsgs },
- { "show-state", no_argument, 0, OptShowState },
- { "wall-clock", no_argument, 0, OptWallClock },
- { "service-by-dig-id", no_argument, 0, OptServiceByDigID },
- { "standby", no_argument, 0, OptStandby },
- { "toggle-power-status", required_argument, 0, OptTogglePowerStatus },
- { "ignore", required_argument, 0, OptIgnore },
- { "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 },
+ { "trace", no_argument, nullptr, OptTrace },
+ { "verbose", no_argument, nullptr, OptVerbose },
+ { "show-msgs", no_argument, nullptr, OptShowMsgs },
+ { "show-state", no_argument, nullptr, OptShowState },
+ { "wall-clock", no_argument, nullptr, OptWallClock },
+ { "service-by-dig-id", no_argument, nullptr, OptServiceByDigID },
+ { "standby", no_argument, nullptr, OptStandby },
+ { "toggle-power-status", required_argument, nullptr, OptTogglePowerStatus },
+ { "ignore", required_argument, nullptr, OptIgnore },
+ { "version", no_argument, nullptr, OptVersion },
+
+ { nullptr, 0, nullptr, 0 }
};
#define STR(x) #x
@@ -320,8 +320,8 @@ int main(int argc, char **argv)
{
std::string device;
struct node node = { };
- const char *driver = NULL;
- const char *adapter = NULL;
+ const char *driver = nullptr;
+ const char *adapter = nullptr;
unsigned toggle_power_status = 0;
char short_options[26 * 2 * 2 + 1];
int idx = 0;
@@ -391,7 +391,7 @@ int main(int argc, char **argv)
show_state = true;
break;
case OptTogglePowerStatus:
- toggle_power_status = strtoul(optarg, NULL, 0);
+ toggle_power_status = strtoul(optarg, nullptr, 0);
break;
case OptIgnore: {
bool all_la = !strncmp(optarg, "all", 3);
@@ -402,7 +402,7 @@ int main(int argc, char **argv)
if (sep)
all_opcodes = !strncmp(sep + 1, "all", 3);
if (!all_la) {
- la = strtoul(optarg, NULL, 0);
+ la = strtoul(optarg, nullptr, 0);
if (la > 15) {
fprintf(stderr, "invalid logical address (> 15)\n");
@@ -412,7 +412,7 @@ int main(int argc, char **argv)
la_mask = 1 << la;
}
if (!all_opcodes) {
- opcode = strtoul(sep + 1, NULL, 0);
+ opcode = strtoul(sep + 1, nullptr, 0);
if (opcode > 255) {
fprintf(stderr, "invalid opcode (> 255)\n");
usage();
diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
index fdc62c8b..83ffcc30 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -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

Privacy Policy