Skip to content

Commit

Permalink
inhibit: normalize variable types
Browse files Browse the repository at this point in the history
When we parse an "u" from an sd_bus_message then we need to do that into
a uint32_t, not a pid_t or uid_t, even if this is likely the same.

Also, let's count objects we keep in memory as size_t as usual.
  • Loading branch information
poettering committed Sep 24, 2018
1 parent 0e6872c commit 2f47ef0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/login/inhibit.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ static int print_inhibitors(sd_bus *bus) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
const char *what, *who, *why, *mode;
unsigned int uid, pid;
unsigned n = 0;
uint32_t uid, pid;
size_t n = 0;
int r;

(void) pager_open(arg_no_pager, false);
Expand Down Expand Up @@ -95,7 +95,7 @@ static int print_inhibitors(sd_bus *bus) {
get_process_comm(pid, &comm);
u = uid_to_name(uid);

printf(" Who: %s (UID "UID_FMT"/%s, PID "PID_FMT"/%s)\n"
printf(" Who: %s (UID %" PRIu32 "/%s, PID %" PRIu32"/%s)\n"
" What: %s\n"
" Why: %s\n"
" Mode: %s\n\n",
Expand All @@ -113,7 +113,7 @@ static int print_inhibitors(sd_bus *bus) {
if (r < 0)
return bus_log_parse_error(r);

printf("%u inhibitors listed.\n", n);
printf("%zu inhibitors listed.\n", n);
return 0;
}

Expand Down

0 comments on commit 2f47ef0

Please sign in to comment.