diff options
author | Roland McGrath <roland@gnu.org> | 1998-10-20 09:48:26 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1998-10-20 09:48:26 +0000 |
commit | caf7ac6e90416c95f67a381835980e3da3570eb0 (patch) | |
tree | 28077a76d06d42200c6a432d37d51e50b377d467 /libps | |
parent | fc40a731d23f893be2cb7699d7e078568d4c210c (diff) |
Add braces to silence gcc warnings.
Diffstat (limited to 'libps')
-rw-r--r-- | libps/ChangeLog | 35 | ||||
-rw-r--r-- | libps/fmt.c | 20 | ||||
-rw-r--r-- | libps/procstat.c | 122 |
3 files changed, 97 insertions, 80 deletions
diff --git a/libps/ChangeLog b/libps/ChangeLog index 73d7612c..72147552 100644 --- a/libps/ChangeLog +++ b/libps/ChangeLog @@ -1,3 +1,11 @@ +1998-10-19 Roland McGrath <roland@baalperazim.frob.com> + + * fmt.c (_fmt_create): Add braces to silence gcc warning. + * procstat.c (summarize_thread_waits): Likewise. + (proc_stat_set_flags): Likewise. + (proc_stat_set_flags): Likewise. + (proc_stat_set_flags): Likewise. + Sat Jun 7 21:35:37 1997 Miles Bader <miles@gnu.ai.mit.edu> * spec.c (ps_emit_wait): Provide slightly better abbreviations for @@ -119,7 +127,7 @@ Mon Jun 3 10:17:43 1996 Miles Bader <miles@gnu.ai.mit.edu> correctly (it's an error_t). * ps.h (struct proc_stat): Add PROC_INFO_VM_ALLOCED, - THREAD_WAITS_VM_ALLOCED, and ARGS_VM_ALLOCED fields, + THREAD_WAITS_VM_ALLOCED, and ARGS_VM_ALLOCED fields, * procstat.c (merge_procinfo) Take a struct proc_stat as an arg, not all the individual fields. Correctly set OLD_PI_HDR. Correctly calculate REALLY_NEED. @@ -133,7 +141,7 @@ Mon Jun 3 10:17:43 1996 Miles Bader <miles@gnu.ai.mit.edu> Sat Jun 1 11:18:58 1996 Miles Bader <miles@gnu.ai.mit.edu> * procstat.c (set_procinfo_flags): New function. - (proc_stat_set_flags): Use it, to get msgport validity testing right. + (proc_stat_set_flags): Use it, to get msgport validity testing right. (merge_procinfo): Take and return HAVE instead of using a reference parameter. Clean up malloced storage if we get an error. @@ -190,7 +198,7 @@ Fri May 24 13:33:14 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> * procstat.c (fetch_procinfo): Always turn on PSTAT_PROC_INFO if proc_getprocinfo returns successfully. (merge_procinfo): Update *HAVE with PSTAT_PROC_INFO from - REALLY_HAVE here. + REALLY_HAVE here. Wed May 22 19:55:04 1996 Miles Bader <miles@gnu.ai.mit.edu> @@ -366,7 +374,7 @@ Wed Feb 14 17:49:17 1996 Miles Bader <miles@gnu.ai.mit.edu> Mon Feb 12 14:34:22 1996 Miles Bader <miles@gnu.ai.mit.edu> - * spec.c (ps_emit_wait): For rpcs, put the port first. + * spec.c (ps_emit_wait): For rpcs, put the port first. Fri Feb 9 15:55:35 1996 Miles Bader <miles@gnu.ai.mit.edu> @@ -455,7 +463,7 @@ Thu Dec 21 12:04:24 1995 Miles Bader <miles@gnu.ai.mit.edu> * fmt.c (ps_fmt_create): Use the new spec fields. (ps_fmt_write_proc_stat): Support new inval field in FMT. - * spec.c (ps_fmt_specs_find): Renamed from find_ps_fmt_spec; now + * spec.c (ps_fmt_specs_find): Renamed from find_ps_fmt_spec; now uses a struct ps_fmt_specs instead of an array of specs. (specs): Renamed from ps_std_fmt_specs; (ps_std_fmt_specs): Now of type struct ps_fmt_specs, pointing to specs. @@ -505,7 +513,7 @@ Sat Dec 16 23:42:27 1995 Miles Bader <miles@gnu.ai.mit.edu> (own_uid): New variable (was function local). * filters.c (ps_own_filter): Depend on PSTAT_OWNER_UID. (ps_own_p): Account for there being no uid. - + Thu Nov 16 12:51:34 1995 Miles Bader <miles@gnu.ai.mit.edu> * write.c (ps_stream_write_field): Trim spaces from BUF. @@ -526,7 +534,7 @@ Wed Nov 15 18:55:26 1995 Miles Bader <miles@gnu.ai.mit.edu> (ps_stream_write_field): Renamed from ps_write_field. (ps_stream_write_int_field): Renamed from ps_write_int_field. (ps_stream_newline): New declaration. - + * fmt.c (ps_fmt_write_titles, ps_fmt_write_proc_stat): Use new write function names. Use new STREAM parameter instead of old one and count. @@ -534,7 +542,7 @@ Wed Nov 15 18:55:26 1995 Miles Bader <miles@gnu.ai.mit.edu> * spec.c (ps_emit_int, ps_emit_nz_int, ps_emit_priority, ps_emit_percent, ps_emit_num_blocks, ps_emit_nice_int, ps_emit_nice_seconds, ps_emit_seconds, ps_emit_uid, ps_emit_uname, - ps_emit_string0, ps_emit_string, ps_emit_tty_name, ps_emit_state): + ps_emit_string0, ps_emit_string, ps_emit_tty_name, ps_emit_state): Ditto. (ps_emit_seconds): Remove leading spaces from what we print. @@ -581,7 +589,7 @@ Tue Oct 31 14:03:53 1995 Miles Bader <miles@gnu.ai.mit.edu> * ps.h (PSTAT_STATE_P_LOGINLDR, PSTAT_STATE_P_WAIT, PSTAT_STATE_P_GETMSG): New flags. * procstat.c (add_preconditions): Don't require PSTAT_EXEC_FLAGS for - getting the state anymore (but do require PSTAT_{TASK,THREAD}_BASIC). + getting the state anymore (but do require PSTAT_{TASK,THREAD}_BASIC). (proc_stat_state_tags): Update to reflect new flags. (proc_stat_set_flags): Set new flags. @@ -605,7 +613,7 @@ Tue Oct 31 14:03:53 1995 Miles Bader <miles@gnu.ai.mit.edu> (ps_get_ppid, ps_get_pgrp, ps_get_session, ps_get_login_col): Use proc_stat_proc_info, not proc_stat_info. (ps_vsize_getter, ps_rsize_getter, ps_rmem_frac_getter, - ps_proc_susp_count_getter): Use PSTAT_TASK_BASIC, not PSTAT_INFO. + ps_proc_susp_count_getter): Use PSTAT_TASK_BASIC, not PSTAT_INFO. (ps_get_vsize, ps_get_rsize, ps_get_rmem_frac, ps_get_proc_susp_count): Use proc_stat_task_basic_info, not proc_stat_info. (ps_cur_priority_getter, ps_base_priority_getter, @@ -613,7 +621,7 @@ Tue Oct 31 14:03:53 1995 Miles Bader <miles@gnu.ai.mit.edu> (ps_usr_time_getter, ps_sys_time_getter, ps_tot_time_getter, ps_cpu_frac_getter, ps_sleep_getter): Use PSTAT_THREAD_BASIC, not PSTAT_THREAD_INFO. - + * filters.c (ps_own_filter): Use PSTAT_PROC_INFO, not PSTAT_INFO. (ps_own_p): Use proc_stat_proc_info, not proc_stat_info. @@ -628,7 +636,7 @@ Tue Oct 31 14:03:53 1995 Miles Bader <miles@gnu.ai.mit.edu> (struct proc_stat): info & info_len --> proc_info & proc_info_len. Add the num_threads, task_basic_info, and thread_rpc fields. thread_basic_info & thread_sched_info are now pointers. - + Mon Oct 9 14:57:48 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * Makefile: Specify shared library dependencies. @@ -660,7 +668,7 @@ Fri Aug 18 16:43:41 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> (ps_emit_state): Use the state_shadows list to turn off some states. * filters.c (ps_not_sess_leader_p, ps_unorphaned_p, ps_parent_p): Use the new state bits. - + Sat Jul 8 13:34:20 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> * tty.c (ps_tty_short_name): That assignment around which extra @@ -830,4 +838,3 @@ Mon Mar 20 20:51:51 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu> * New ChangeLog, moved into canonical directory structure. Old ChangeLog is in .../hurd/utils/ps.ChangeLog. - diff --git a/libps/fmt.c b/libps/fmt.c index 764711ae..eae08ffe 100644 --- a/libps/fmt.c +++ b/libps/fmt.c @@ -1,7 +1,7 @@ /* Implements the ps_fmt type, which describes how to output a user-readable version of a proc_stat. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -240,11 +240,13 @@ _fmt_create (char *src, int posix, struct ps_fmt_specs *fmt_specs, } if (! field->title) - /* No explicit title specified in the fmt string. */ - if (field->spec->title) - field->title = field->spec->title; /* But the spec has one. */ - else - field->title = field->spec->name; /* Just use the field name. */ + { + /* No explicit title specified in the fmt string. */ + if (field->spec->title) + field->title = field->spec->title; /* But the spec has one. */ + else + field->title = field->spec->name; /* Just use field name. */ + } /* Add FIELD's required pstat_flags to FMT's set */ needs |= ps_getter_needs (ps_fmt_spec_getter (field->spec)); @@ -255,7 +257,7 @@ _fmt_create (char *src, int posix, struct ps_fmt_specs *fmt_specs, field->precision = field->spec->precision; field->flags = (field->spec->flags & ~clr_flags) ^ inv_flags; - + if (quoted_name && *src == '}') /* Skip optional trailing `}' after the spec name. */ src++; @@ -324,7 +326,7 @@ ps_fmt_creation_error (char *src, int posix, struct ps_fmt_specs *fmt_specs, } /* Free FMT, and any resources it consumes. */ -void +void ps_fmt_free (struct ps_fmt *fmt) { FREE (fmt->src); @@ -475,7 +477,7 @@ ps_fmt_squash (struct ps_fmt *fmt, int (*fn)(struct ps_fmt_field *field)) { /* Save the old prefix, in case we're deleting the first field, and need to prepend it to the next field. */ - const char *beg_pfx = field->pfx; + const char *beg_pfx = field->pfx; int beg_pfx_len = field->pfx_len; nfields--; diff --git a/libps/procstat.c b/libps/procstat.c index 6b1c38cf..b9a3e632 100644 --- a/libps/procstat.c +++ b/libps/procstat.c @@ -1,6 +1,6 @@ /* The proc_stat type, which holds information about a hurd process. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -43,7 +43,7 @@ typedef threadinfo_data_t *threadinfo_t; /* Return the PSTAT_STATE_ bits describing the state of an individual thread, from that thread's thread_basic_info_t struct */ -static int +static int thread_state (thread_basic_info_t bi) { int state = 0; @@ -93,7 +93,7 @@ thread_state (thread_basic_info_t bi) (PSTAT_PROCINFO_TASK_THREAD_DEP | PSTAT_PROC_INFO | PSTAT_TASK_BASIC) /* The set of PSTAT_ flags that we get using proc_getprocinfo. */ -#define PSTAT_PROCINFO PSTAT_PROCINFO_TASK +#define PSTAT_PROCINFO PSTAT_PROCINFO_TASK /* The set of things in PSTAT_PROCINFO that we will not attempt to refetch on subsequent getprocinfo calls. */ @@ -156,7 +156,7 @@ fetch_procinfo (process_t server, pid_t pid, vm_alloced memory for the procinfo structure returned by getprocinfo. Here we just give enough for four threads. */ #define PROCINFO_MALLOC_SIZE \ - (sizeof (struct procinfo) + 4 * sizeof (threadinfo_data_t)) + (sizeof (struct procinfo) + 4 * sizeof (threadinfo_data_t)) #define WAITS_MALLOC_SIZE 128 @@ -272,7 +272,7 @@ merge_procinfo (struct proc_stat *ps, ps_flags_t need, ps_flags_t have) /* Returns FLAGS augmented with any other flags that are necessary preconditions to setting them. */ -static ps_flags_t +static ps_flags_t add_preconditions (ps_flags_t flags, struct ps_context *context) { /* Implement any inter-flag dependencies: if the new flags in FLAGS depend on @@ -453,7 +453,7 @@ summarize_thread_sched_info (struct procinfo *pi) bzero (tsi, sizeof *tsi); for (i = 0; i < pi->nthreads; i++) - if (! pi->threadinfos[i].died + if (! pi->threadinfos[i].died && ! (pi->threadinfos[i].pis_bi.flags & TH_FLAGS_IDLE)) { thread_sched_info_t si = &pi->threadinfos[i].pis_si; @@ -504,33 +504,35 @@ summarize_thread_waits (struct procinfo *pi, char *waits, size_t waits_len, for (i = 0; i < pi->nthreads; i++) if (! pi->threadinfos[i].died) - if (next_wait > waits + waits_len) - break; - else - { - int left = waits + waits_len - next_wait; - - if (pi->threadinfos[i].pis_bi.flags & TH_FLAGS_IDLE) - ; /* kernel idle thread; ignore */ - else if (strncmp (next_wait, "msgport", left) == 0 - || strncmp (next_wait, "itimer", left) == 0) - ; /* libc internal threads; ignore. */ - else if (*wait) - /* There are multiple user threads. Punt. */ - { - *wait = "*"; - *rpc = 0; - break; - } - else - { - *wait = next_wait; - *rpc = pi->threadinfos[i].rpc_block; - } - - /* Advance NEXT_WAIT to the next wait string. */ - next_wait += strnlen (next_wait, left) + 1; - } + { + if (next_wait > waits + waits_len) + break; + else + { + int left = waits + waits_len - next_wait; + + if (pi->threadinfos[i].pis_bi.flags & TH_FLAGS_IDLE) + ; /* kernel idle thread; ignore */ + else if (strncmp (next_wait, "msgport", left) == 0 + || strncmp (next_wait, "itimer", left) == 0) + ; /* libc internal threads; ignore. */ + else if (*wait) + /* There are multiple user threads. Punt. */ + { + *wait = "*"; + *rpc = 0; + break; + } + else + { + *wait = next_wait; + *rpc = pi->threadinfos[i].rpc_block; + } + + /* Advance NEXT_WAIT to the next wait string. */ + next_wait += strnlen (next_wait, left) + 1; + } + } } /* Returns the number of threads in PI that aren't marked dead. */ @@ -875,13 +877,15 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) ps->state = 0; if (have & PSTAT_THREAD_BASIC) - /* Thread states. */ - if (have & PSTAT_THREAD) - ps->state |= thread_state (ps->thread_basic_info); - else - /* For a process, we use the thread list instead of - PS->thread_basic_info because it contains more information. */ - ps->state |= summarize_thread_states (ps->proc_info); + { + /* Thread states. */ + if (have & PSTAT_THREAD) + ps->state |= thread_state (ps->thread_basic_info); + else + /* For a process, we use the thread list instead of + PS->thread_basic_info because it contains more information. */ + ps->state |= summarize_thread_states (ps->proc_info); + } if (have & PSTAT_PROC_INFO) /* Process state. */ @@ -921,15 +925,17 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) ps->args_len = 100; ps->args = buf; if (ps->args) - if (proc_getprocargs (server, ps->pid, &ps->args, &ps->args_len)) - free (buf); - else - { - have |= PSTAT_ARGS; - ps->args_vm_alloced = (ps->args != buf); - if (ps->args_vm_alloced) - free (buf); - } + { + if (proc_getprocargs (server, ps->pid, &ps->args, &ps->args_len)) + free (buf); + else + { + have |= PSTAT_ARGS; + ps->args_vm_alloced = (ps->args != buf); + if (ps->args_vm_alloced) + free (buf); + } + } } /* The ctty id port; note that this is just a magic cookie; @@ -967,13 +973,15 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) /* A ps_user object for the process's owner. */ if (NEED (PSTAT_OWNER, PSTAT_OWNER_UID)) - if (ps->owner_uid < 0) - { - ps->owner = 0; + { + if (ps->owner_uid < 0) + { + ps->owner = 0; + have |= PSTAT_OWNER; + } + else if (! ps_context_find_user (ps->context, ps->owner_uid, &ps->owner)) have |= PSTAT_OWNER; - } - else if (! ps_context_find_user (ps->context, ps->owner_uid, &ps->owner)) - have |= PSTAT_OWNER; + } /* A ps_tty for the process's controlling terminal, or NULL if it doesn't have one. */ @@ -1005,7 +1013,7 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) /* ---------------------------------------------------------------- */ /* Discard PS and any resources it holds. */ -void +void _proc_stat_free (ps) struct proc_stat *ps; { @@ -1019,7 +1027,7 @@ _proc_stat_free (ps) ? mach_port_deallocate(mach_task_self (), (ps->port)) : 0) /* If FLAG is set in PS's flags, then if VM_ALLOCED is zero, free the malloced - field MEM in PS; othrewise, vm_deallocate MEM, consisting of SIZE + field MEM in PS; othrewise, vm_deallocate MEM, consisting of SIZE elements of type ELTYPE, *unless* MEM == SBUF, which usually means that MEM points to a static buffer somewhere instead of vm_alloc'd memory. */ |