From 0cae3b5085ef12ee74d8e03ac9b2e581632fbdd9 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Thu, 3 Apr 2003 04:54:56 +0000 Subject: [PATCH] added stefans patches --- ChangeLog | 4 ++++ src/fuser.c | 19 ++++++++++++------- src/killall.c | 3 ++- src/pstree.c | 12 ++++++------ src/signals.c | 3 +++ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 443088f..a453b66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ Changes in 21.3 =============== +2003-04-03 Craig Small + * More fixes for types, also some GCC 3.2 fixes, thanks to + Stefan at SuSE + 2002-09-27 Craig Small * Changed a long to a long long in pstree. diff --git a/src/fuser.c b/src/fuser.c index a3cca53..7fd47bc 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -180,13 +180,12 @@ parse_net_file (SPACE_DSC * dsc,char *filename, NET_CACHE **lastptr,int version perror ("malloc"); exit (1); } - if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d " #ifdef INO_T_IS_LONG_LONG - "%Ld", &new->lcl_port, rmt_addr, &new->rmt_port, + if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %Ld", &new->lcl_port, rmt_addr, &new->rmt_port, #elif defined(INO_T_IS_INT) - "%d", &new->lcl_port, rmt_addr, &new->rmt_port, + if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %d", &new->lcl_port, rmt_addr, &new->rmt_port, #else - "%d", &new->lcl_port, rmt_addr, &new->rmt_port, + if (sscanf (line, "%*d: %*x:%x %64[0-9A-Fa-f]:%x %*x %*x:%*x %*x:%*x %*x %*d %*d %d", &new->lcl_port, rmt_addr, &new->rmt_port, #endif &new->ino) != 4) { @@ -474,7 +473,7 @@ scan_fd (void) } empty = 1; while ((de = readdir (dir)) != NULL) - if ((pid = atoi (de->d_name)) != 0) + if ((pid = (pid_t)atoi (de->d_name)) != 0) { empty = 0; if (asprintf (&path, "%s/%d", PROC_BASE, pid) < 0) @@ -650,7 +649,7 @@ show_files_or_kill (void) const struct passwd *pw; const char *user, *scan; char tmp[10], *path, comm[COMM_LEN + 1]; - int length, header, first, dummy; + int length, header, first, dummy, last_namelen = 0; header = 1; for (file = files; file; file = file->next) if (file->name && (file->items || all)) @@ -661,7 +660,7 @@ show_files_or_kill (void) header = 0; } length = 0; - for (scan = file->name; *scan; scan++) + for (scan = file->name; scan && *scan; scan++) if (*scan == '\\') length += printf ("\\\\"); else if (*scan > ' ' && *scan <= '~') @@ -673,6 +672,12 @@ show_files_or_kill (void) length += printf ("\\%03o", *scan); if (file->name_space) length += printf ("/%s", file->name_space->name); + + if (length > 0) + last_namelen=length; + else + printf("\n%*.*s",last_namelen,last_namelen," "); + if (!(file->flags & FLAG_VERB)) { putchar (':'); diff --git a/src/killall.c b/src/killall.c index a39ec8e..83ce26e 100644 --- a/src/killall.c +++ b/src/killall.c @@ -11,6 +11,7 @@ #endif #include +#include #include #include #include @@ -131,7 +132,7 @@ kill_all (int signal, int names, char **namelist) pids = 0; while ( (de = readdir (dir)) != NULL) { - if (!(pid = atoi (de->d_name)) || pid == self) + if (!(pid = (pid_t) atoi (de->d_name)) || pid == self) continue; if (pids == max_pids) { diff --git a/src/pstree.c b/src/pstree.c index b252846..60051aa 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -181,12 +181,12 @@ out_scontext ( security_id_t sid ) rv = security_sid_to_context((int)sid, buf, &len); if ( rv ) { - out_string("`??'"); /* punt */ + out_string("`??\'"); /* punt */ } else { out_string("`"); out_string(buf); - out_string("'"); + out_string("\'"); } } #endif /*FLASK_LINUX*/ @@ -454,7 +454,7 @@ dump_tree (PROC * current, int level, int rep, int leaf, int last, len = 0; for (here = current->argv[i]; *here; here++) len += *here > ' ' && *here <= '~' ? 1 : 4; - if (cur_x + len <= output_width - (i == current->argc - 1 ? 0 : 4)) + if (cur_x + len <= output_width - (i == current->argc - 1 ? 0 : 4) || !trunc) for (here = current->argv[i]; *here; here++) if (*here > ' ' && *here <= '~') out_char (*here); @@ -591,7 +591,7 @@ read_proc (void) } empty = 1; while ((de = readdir (dir)) != NULL) - if ((pid = atoi (de->d_name)) != 0) + if ((pid = (pid_t) atoi (de->d_name)) != 0) { if (!(path = malloc (strlen (PROC_BASE) + strlen (de->d_name) + 10))) exit (2); @@ -627,7 +627,7 @@ read_proc (void) if (fscanf (file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy, &ppid) == 4) - */ + */ if (!print_args) #ifdef FLASK_LINUX add_proc(comm, pid, ppid, st.st_uid, NULL, 0, sid); @@ -840,7 +840,7 @@ main (int argc, char **argv) if (optind == argc - 1) { if (isdigit (*argv[optind])) { - if (!(pid = atoi (argv[optind++]))) + if (!(pid = (pid_t) atoi (argv[optind++]))) usage (); } else if (!(pw = getpwnam (argv[optind++]))) diff --git a/src/signals.c b/src/signals.c index 46e9ccf..a8295d3 100644 --- a/src/signals.c +++ b/src/signals.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "signals.h" @@ -52,6 +53,8 @@ get_signal (char *name, const char *cmd) if (isdigit (*name)) return atoi (name); + if (!strncmp("SIG", name, 3)) + name += 3; for (walk = signals; walk->name; walk++) if (!strcmp (walk->name, name)) break; -- 2.40.0