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>
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;
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;