From a35d9f1a676f430e1dbbb555f327cd7a40df37f7 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 12 Sep 2008 22:43:10 +0000 Subject: [PATCH] * cygcheck.cc (pathlike::check_existence): Remove class name from declaration. (display_internet_error): Use proper format specifier for DWORD. (environ): Remove unneeded declaration. (main): Use brace around nested if to avoid an overly-helpful compiler warning. * dump_setup.cc (parse_filename): Reorganize nested if to avoid an overly-helpful compiler warning. * path.cc (GUID_shortcut): Use braces around part of initializer which needs them. (conv_fstab_spaces): Parenthesize assignment in while loop to avoid a compiler warning. (struct opt): Make static. * ps.cc (main): Reorganize nested if to avoid an overly-helpful compiler warning. * regtool.cc: Make some anonymous structs static to avoid a compiler warning. * ssp.c (lookup_thread_id): Initialize *tix to zero to avoid potential uninitialized use. * strace.cc (add_child): Use proper format specifier for DWORD. (remove_child): Ditto. (proc_child): Ditto. --- winsup/utils/ChangeLog | 25 +++++++++++++++++++++++++ winsup/utils/cygcheck.cc | 23 +++++++++++------------ winsup/utils/dump_setup.cc | 37 +++++++++++++++++++------------------ winsup/utils/path.cc | 10 +++++----- winsup/utils/ps.cc | 17 +++++++++-------- winsup/utils/regtool.cc | 5 ++--- winsup/utils/ssp.c | 4 +++- winsup/utils/strace.cc | 6 +++--- 8 files changed, 77 insertions(+), 50 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 26bf212b5..217923921 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,28 @@ +2008-09-12 Christopher Faylor + + * cygcheck.cc (pathlike::check_existence): Remove class name from + declaration. + (display_internet_error): Use proper format specifier for DWORD. + (environ): Remove unneeded declaration. + (main): Use brace around nested if to avoid an overly-helpful compiler + warning. + * dump_setup.cc (parse_filename): Reorganize nested if to avoid an + overly-helpful compiler warning. + * path.cc (GUID_shortcut): Use braces around part of initializer which + needs them. + (conv_fstab_spaces): Parenthesize assignment in while loop to avoid a + compiler warning. + (struct opt): Make static. + * ps.cc (main): Reorganize nested if to avoid an overly-helpful + compiler warning. + * regtool.cc: Make some anonymous structs static to avoid a compiler + warning. + * ssp.c (lookup_thread_id): Initialize *tix to zero to avoid potential + uninitialized use. + * strace.cc (add_child): Use proper format specifier for DWORD. + (remove_child): Ditto. + (proc_child): Ditto. + 2008-08-27 Christopher Faylor * cygcheck.cc (nuke): Use malloc rather than alloca for environment diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc index 0fc27fcd2..9a04cb41b 100644 --- a/winsup/utils/cygcheck.cc +++ b/winsup/utils/cygcheck.cc @@ -124,9 +124,9 @@ struct pathlike { char *dir; bool issys; - void pathlike::check_existence (const char *fn, int showall, int verbose, - char* first, const char *ext1 = "", - const char *ext2 = ""); + void check_existence (const char *fn, int showall, int verbose, + char* first, const char *ext1 = "", + const char *ext2 = ""); }; pathlike *paths; @@ -201,7 +201,7 @@ display_internet_error (const char *message, ...) sizeof (err_buf), NULL) == 0) strcpy (err_buf, "(Unknown error)"); - fprintf (stderr, "cygcheck: %s: %s (win32 error %d)\n", message, + fprintf (stderr, "cygcheck: %s: %s (win32 error %lu)\n", message, err_buf, err); } else @@ -901,9 +901,6 @@ cygcheck (const char *app) return track_down (papp, ".exe", 0); } - -extern char **environ; - struct RegInfo { RegInfo *prev; @@ -2115,11 +2112,13 @@ main (int argc, char **argv) if (posixly == NULL) putenv ("POSIXLY_CORRECT="); - if (argc == 0 && !sysinfo && !keycheck && !check_setup && !list_package) - if (givehelp) - usage (stdout, 0); - else - usage (stderr, 1); + if ((argc == 0) && !sysinfo && !keycheck && !check_setup && !list_package) + { + if (givehelp) + usage (stdout, 0); + else + usage (stderr, 1); + } if ((check_setup || sysinfo || find_package || list_package || grep_packages) && keycheck) diff --git a/winsup/utils/dump_setup.cc b/winsup/utils/dump_setup.cc index 3e71f1a02..e3dacde6c 100644 --- a/winsup/utils/dump_setup.cc +++ b/winsup/utils/dump_setup.cc @@ -91,24 +91,25 @@ parse_filename (const char *in_fn, fileparse& f) f.pkg[0] = f.what[0] = '\0'; p = base (fn); for (ver = p; *ver; ver++) - if (*ver == '-') - if (isdigit (ver[1])) - { - *ver++ = '\0'; - strcpy (f.pkg, p); - break; - } - else if (strcasecmp (ver, "-src") == 0 || - strcasecmp (ver, "-patch") == 0) - { - *ver++ = '\0'; - strcpy (f.pkg, p); - strcpy (f.what, strlwr (ver)); - strcpy (f.pkgtar, p); - strcat (f.pkgtar, f.tail); - ver = strchr (ver, '\0'); - break; - } + if (*ver != '-') + continue; + else if (isdigit (ver[1])) + { + *ver++ = '\0'; + strcpy (f.pkg, p); + break; + } + else if (strcasecmp (ver, "-src") == 0 || + strcasecmp (ver, "-patch") == 0) + { + *ver++ = '\0'; + strcpy (f.pkg, p); + strcpy (f.what, strlwr (ver)); + strcpy (f.pkgtar, p); + strcat (f.pkgtar, f.tail); + ver = strchr (ver, '\0'); + break; + } if (!f.pkg[0]) strcpy (f.pkg, p); diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index 396badb79..787467f1d 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -35,8 +35,8 @@ details. */ }) -static const GUID GUID_shortcut - = { 0x00021401L, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46 }; +static const GUID GUID_shortcut = + {0x00021401L, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}}; enum { WSH_FLAG_IDLIST = 0x01, /* Contains an ITEMIDLIST. */ @@ -276,7 +276,7 @@ inline char * conv_fstab_spaces (char *field) { register char *sp = field; - while (sp = strstr (sp, "\\040")) + while ((sp = strstr (sp, "\\040")) != NULL) { *sp++ = ' '; memmove (sp, sp + 3, strlen (sp + 3) + 1); @@ -284,7 +284,7 @@ conv_fstab_spaces (char *field) return field; } -struct opt +static struct opt { const char *name; unsigned val; @@ -503,7 +503,7 @@ from_fstab (bool user, PWCHAR path, PWCHAR path_end) } #endif -int +static int mnt_sort (const void *a, const void *b) { const mnt_t *ma = (const mnt_t *) a; diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc index 091e7413a..2ad2a39a5 100644 --- a/winsup/utils/ps.cc +++ b/winsup/utils/ps.cc @@ -344,14 +344,15 @@ main (int argc, char *argv[]) if ((proc_id > 0) && (p->pid != proc_id)) continue; - if (!aflag) - if (p->version >= EXTERNAL_PINFO_VERSION_32_BIT) - { - if (p->uid32 != (__uid32_t) uid) - continue; - } - else if (p->uid != uid) - continue; + if (aflag) + /* nothing to do */; + else if (p->version >= EXTERNAL_PINFO_VERSION_32_BIT) + { + if (p->uid32 != (__uid32_t) uid) + continue; + } + else if (p->uid != uid) + continue; char status = ' '; if (p->process_state & PID_STOPPED) status = 'S'; diff --git a/winsup/utils/regtool.cc b/winsup/utils/regtool.cc index 4bda9e646..7a853be85 100644 --- a/winsup/utils/regtool.cc +++ b/winsup/utils/regtool.cc @@ -202,7 +202,7 @@ Fail (DWORD rv) exit (1); } -struct +static struct { const char *string; HKEY key; @@ -865,8 +865,7 @@ cmd_save () return 0; } - -struct +static struct { const char *name; int (*func) (); diff --git a/winsup/utils/ssp.c b/winsup/utils/ssp.c index 6d81ddb63..c7370d94d 100644 --- a/winsup/utils/ssp.c +++ b/winsup/utils/ssp.c @@ -161,10 +161,12 @@ static HANDLE lookup_thread_id (DWORD threadId, int *tix) { int i; + *tix = 0; for (i=0; ihproc = hproc; processes++; if (!quiet) - fprintf (stderr, "Windows process %d attached\n", id); + fprintf (stderr, "Windows process %lu attached\n", id); } } @@ -148,7 +148,7 @@ remove_child (DWORD id) c->next = c1->next; free (c1); if (!quiet) - fprintf (stderr, "Windows process %d detached\n", id); + fprintf (stderr, "Windows process %lu detached\n", id); processes--; return; } @@ -650,7 +650,7 @@ proc_child (unsigned mask, FILE *ofile, pid_t pid) { status = DBG_EXCEPTION_NOT_HANDLED; if (ev.u.Exception.dwFirstChance) - fprintf (ofile, "--- Process %u, exception %p at %p\n", ev.dwProcessId, + fprintf (ofile, "--- Process %lu, exception %p at %p\n", ev.dwProcessId, ev.u.Exception.ExceptionRecord.ExceptionCode, ev.u.Exception.ExceptionRecord.ExceptionAddress); }