misc: eliminate a couple of miscellaneous gcc warnings
This commit just addresses those warnings shown below. Reference(s): proc/sysinfo.c: In function `getrunners': proc/sysinfo.c:491:26: warning: `%s' directive writing up to 255 bytes into a region of size 26 [-Wformat-overflow=] 491 | sprintf(tbuf, "/proc/%s/stat", ent->d_name); | ^~ pgrep.c: In function `select_procs': pgrep.c:591:11: warning: suggest explicit braces to avoid ambiguous `else' [-Wdangling-else] 591 | else if (opt_older) | ^ Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
71d49f168a
commit
e319650278
3
pgrep.c
3
pgrep.c
@ -588,8 +588,9 @@ static struct el * select_procs (int *num)
|
||||
match = match_strlist (tty, opt_term);
|
||||
}
|
||||
}
|
||||
else if (opt_older)
|
||||
else if (opt_older) {
|
||||
if(now - uptime_secs + (task.start_time / Hertz) + opt_older > now) match = 0;
|
||||
}
|
||||
else if (opt_runstates) {
|
||||
match = 0;
|
||||
if (strchr(opt_runstates, task.state)) match = 1;
|
||||
|
@ -488,7 +488,7 @@ static void getrunners(unsigned int *restrict running, unsigned int *restrict bl
|
||||
char c;
|
||||
|
||||
if (!isdigit(ent->d_name[0])) continue;
|
||||
sprintf(tbuf, "/proc/%s/stat", ent->d_name);
|
||||
snprintf(tbuf, sizeof(tbuf), "/proc/%s/stat", ent->d_name);
|
||||
|
||||
fd = open(tbuf, O_RDONLY, 0);
|
||||
if (fd == -1) continue;
|
||||
|
Loading…
Reference in New Issue
Block a user