more of -Wall fixes from Cristian Ionescu-Idbohrn.

Some are fixing real bugs.

function                                             old     new   delta
syslogd_main                                         938     958     +20
get_signum                                           136     143      +7
obj_load                                             777     782      +5
recv_from_to                                         210     214      +4
get_next_block                                      1795    1799      +4
display_topmem_process_list                         1117    1121      +4
logread_main                                         484     487      +3
buffer_fill_and_print                                 73      76      +3
kill_main                                            687     689      +2
ll_remember_index                                    240     241      +1
do_stats                                             452     453      +1
if_readconf                                          166     165      -1
display_process_list                                1192    1191      -1
run_applet_and_exit                                  507     505      -2
print_signames                                        33      31      -2
parse_one_line                                      1092    1090      -2
find_out_spec                                         57      55      -2
add_ksymoops_symbols                                 421     419      -2
ash_main                                            1407    1402      -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/8 up/down: 54/-17)            Total: 37 bytes
This commit is contained in:
Denis Vlasenko
2008-05-15 21:30:45 +00:00
parent 43d5d429fd
commit 6b06cb80be
43 changed files with 113 additions and 110 deletions

View File

@@ -106,19 +106,19 @@ int kill_main(int argc, char **argv)
argc--;
do_it_now:
pid = getpid();
if (killall5) {
pid_t sid;
procps_status_t* p = NULL;
/* Find out our own session id */
sid = getsid(pid);
/* Now stop all processes */
kill(-1, SIGSTOP);
/* Find out our own session id */
pid = getpid();
sid = getsid(pid);
/* Now kill all processes except our session */
while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID))) {
if (p->sid != sid && p->pid != pid && p->pid != 1)
if (p->sid != (unsigned)sid && p->pid != (unsigned)pid && p->pid != 1)
kill(p->pid, signo);
}
/* And let them continue */
@@ -134,7 +134,6 @@ do_it_now:
if (killall) {
/* Looks like they want to do a killall. Do that */
pid = getpid();
while (arg) {
pid_t* pidList;

View File

@@ -115,7 +115,7 @@ int pgrep_main(int argc ATTRIBUTE_UNUSED, char **argv)
cmd = proc->comm;
/* NB: OPT_INVERT is always 0 or 1 */
if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */
&& (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == strlen(cmd)))) ^ OPT_INVERT
&& (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == (regoff_t)strlen(cmd)))) ^ OPT_INVERT
) {
matched_pid = proc->pid;
if (OPT_LAST) {

View File

@@ -59,7 +59,7 @@ int pidof_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (opt & OPT_OMIT) {
llist_t *omits_p = omits;
while (omits_p) {
if (xatoul(omits_p->data) == *pl) {
if (xatoul(omits_p->data) == (unsigned long)(*pl)) {
goto omitting;
}
omits_p = omits_p->link;

View File

@@ -310,7 +310,7 @@ static ps_out_t* new_out_t(void)
static const ps_out_t* find_out_spec(const char *name)
{
int i;
unsigned i;
for (i = 0; i < ARRAY_SIZE(out_spec); i++) {
if (!strcmp(name, out_spec[i].name))
return &out_spec[i];

View File

@@ -53,7 +53,7 @@ typedef struct jiffy_counts_t {
the next. Used for finding deltas. */
typedef struct save_hist {
unsigned long ticks;
unsigned pid;
pid_t pid;
} save_hist;
typedef int (*cmp_funcp)(top_status_t *P, top_status_t *Q);
@@ -317,7 +317,7 @@ static unsigned long display_header(int scr_width)
fclose(fp);
/* output memory info */
if (scr_width > sizeof(scrbuf))
if (scr_width > (int)sizeof(scrbuf))
scr_width = sizeof(scrbuf);
snprintf(scrbuf, scr_width,
"Mem: %luK used, %luK free, %luK shrd, %luK buff, %luK cached",
@@ -481,7 +481,7 @@ static NOINLINE void display_process_list(int count, int scr_width)
, SHOW_STAT(pcpu)
#endif
);
if (col + 1 < scr_width)
if ((int)(col + 1) < scr_width)
read_cmdline(line_buf + col, scr_width - col - 1, s->pid, s->comm);
fputs(line_buf, stdout);
/* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,
@@ -584,7 +584,7 @@ static char *grab_number(char *str, const char *match, unsigned sz)
static void display_topmem_header(int scr_width)
{
char linebuf[128];
int i;
unsigned i;
FILE *fp;
union {
struct {
@@ -703,7 +703,7 @@ static NOINLINE void display_topmem_process_list(int count, int scr_width)
ulltoa6_and_space(s->dirty_sh, &line_buf[6*6]);
ulltoa6_and_space(s->stack , &line_buf[7*6]);
line_buf[8*6] = '\0';
if (scr_width > MIN_WIDTH) {
if (scr_width > (int)MIN_WIDTH) {
read_cmdline(&line_buf[8*6], scr_width - MIN_WIDTH, s->pid, s->comm);
}
printf("\n""%.*s", scr_width, line_buf);