Normalize on PATH_MAX instead of MAXPATHLEN throughout.
authorPedro Alves <palves@redhat.com>
Mon, 1 Jul 2013 11:28:30 +0000 (11:28 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 1 Jul 2013 11:28:30 +0000 (11:28 +0000)
With the pathmax gnulib module in place, we can use PATH_MAX
consistently throughout, instead of the current mixbag of PATH_MAX and
MAXPATHLEN uses.  It's no longer necessary to include sys/param.h
(supposedly, I can't check all ports touched here) for MAXPATHLEN.

Don't remove sys/param.h from GDB's configure.ac, as later tests in
the file use HAVE_SYS_PARAM_H checks.

Tested on x86_64 Fedora 17.

Also cross-built for --host=i686-w64-mingw32, and --host=i586-pc-msdosdjgpp.

gdb/
2013-07-01  Pedro Alves  <palves@redhat.com>

* defs.h: Include "pathmax.h".
* utils.c: Don't include sys/param.h.
(gdb_realpath): Remove code that checks for MAXPATHLEN.
* solib-ia64-hpux.c (ia64_hpux_handle_load_event): Use PATH_MAX
instead of MAXPATHLEN.
* solib-sunos.c: Don't include sys/param.h.
* xcoffread.c: Don't include sys/param.h.
* bsd-kvm.c: Don't include sys/param.h.
* darwin-nat.c: Don't include sys/param.h.
(darwin_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
* darwin-nat-info.c: Don't include sys/param.h.
* fbsd-nat.c (fbsd_pid_to_exec_file): Use PATH_MAX instead of
MAXPATHLEN.
* i386obsd-nat.c: Don't include sys/param.h.
* inf-child.c: Don't include sys/param.h.
(inf_child_fileio_readlink): Use PATH_MAX instead of MAXPATHLEN.
* linux-fork.c: Don't include sys/param.h.
(fork_save_infrun_state): Use PATH_MAX instead of MAXPATHLEN.
* linux-nat.c: Don't include sys/param.h.
(linux_child_pid_to_exec_file, linux_proc_pending_signals)
(linux_proc_pending_signals): Use PATH_MAX instead of MAXPATHLEN.
* m68klinux-nat.c: Don't include sys/param.h.
* nbsd-nat.c: Don't include sys/param.h.
(nbsd_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
* ppc-linux-nat.c: Don't include sys/param.h.
* rs6000-nat.c: Don't include sys/param.h.
* spu-linux-nat.c. Don't include sys/param.h.
* windows-nat.c: Don't include sys/param.h.
* xtensa-linux-nat.c: Don't include sys/param.h.
* config/i386/nm-fbsd.h: Don't include sys/param.h.

gdb/gdbserver/
2013-07-01  Pedro Alves  <palves@redhat.com>

* server.h: Include "pathmax.h".
* linux-low.c: Don't include sys/param.h.
(linux_pid_exe_is_elf_64_file): Use PATH_MAX instead of
MAXPATHLEN.
* win32-low.c: Don't include sys/param.h.
(win32_create_inferior): Use PATH_MAX instead of MAXPATHLEN.

26 files changed:
gdb/ChangeLog
gdb/bsd-kvm.c
gdb/config/i386/nm-fbsd.h
gdb/darwin-nat-info.c
gdb/darwin-nat.c
gdb/defs.h
gdb/fbsd-nat.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c
gdb/gdbserver/server.h
gdb/gdbserver/win32-low.c
gdb/i386obsd-nat.c
gdb/inf-child.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/m68klinux-nat.c
gdb/nbsd-nat.c
gdb/ppc-linux-nat.c
gdb/rs6000-nat.c
gdb/solib-ia64-hpux.c
gdb/solib-sunos.c
gdb/spu-linux-nat.c
gdb/utils.c
gdb/windows-nat.c
gdb/xcoffread.c
gdb/xtensa-linux-nat.c

index 2c71fdd7607819d20eaf39abf1b1566773260b48..0ecad53a3c57bbf67ebe34f96f2e5fbe870285a1 100644 (file)
@@ -1,3 +1,36 @@
+2013-07-01  Pedro Alves  <palves@redhat.com>
+
+       * defs.h: Include "pathmax.h".
+       * utils.c: Don't include sys/param.h.
+       (gdb_realpath): Remove code that checks for MAXPATHLEN.
+       * solib-ia64-hpux.c (ia64_hpux_handle_load_event): Use PATH_MAX
+       instead of MAXPATHLEN.
+       * solib-sunos.c: Don't include sys/param.h.
+       * xcoffread.c: Don't include sys/param.h.
+       * bsd-kvm.c: Don't include sys/param.h.
+       * darwin-nat.c: Don't include sys/param.h.
+       (darwin_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
+       * darwin-nat-info.c: Don't include sys/param.h.
+       * fbsd-nat.c (fbsd_pid_to_exec_file): Use PATH_MAX instead of
+       MAXPATHLEN.
+       * i386obsd-nat.c: Don't include sys/param.h.
+       * inf-child.c: Don't include sys/param.h.
+       (inf_child_fileio_readlink): Use PATH_MAX instead of MAXPATHLEN.
+       * linux-fork.c: Don't include sys/param.h.
+       (fork_save_infrun_state): Use PATH_MAX instead of MAXPATHLEN.
+       * linux-nat.c: Don't include sys/param.h.
+       (linux_child_pid_to_exec_file, linux_proc_pending_signals)
+       (linux_proc_pending_signals): Use PATH_MAX instead of MAXPATHLEN.
+       * m68klinux-nat.c: Don't include sys/param.h.
+       * nbsd-nat.c: Don't include sys/param.h.
+       (nbsd_pid_to_exec_file): Use PATH_MAX instead of MAXPATHLEN.
+       * ppc-linux-nat.c: Don't include sys/param.h.
+       * rs6000-nat.c: Don't include sys/param.h.
+       * spu-linux-nat.c. Don't include sys/param.h.
+       * windows-nat.c: Don't include sys/param.h.
+       * xtensa-linux-nat.c: Don't include sys/param.h.
+       * config/i386/nm-fbsd.h: Don't include sys/param.h.
+
 2013-07-01  Pedro Alves  <palves@redhat.com>
 
        * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add pathmax.
index 1e43ccc936cfcfec84fbc71e7bc5cde0f378ceed..dd0ef06aa43d74610c2c3a94c96cec22eaf5fc9b 100644 (file)
@@ -35,7 +35,6 @@
 #endif
 #include <paths.h>
 #include "readline/readline.h"
-#include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/user.h>
 
index 8da0bacf757d218c4bbae103bbfb78aed71e965c..b25dadc0adbda50c232f3fb0818d1f297d5028ba 100644 (file)
@@ -20,8 +20,4 @@
 #ifndef NM_FBSD_H
 #define NM_FBSD_H
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
 #endif /* nm-fbsd.h */
index e480cd79d5477d7429d230bbf028f18bda1acbe7..bdc288977771a2dabb5eb341a6219dd734e8e3d9 100644 (file)
@@ -35,7 +35,6 @@
 #include "gdbcmd.h"
 #include "inferior.h"
 
-#include <sys/param.h>
 #include <sys/sysctl.h>
 
 #include "darwin-nat.h"
index cbf1f787b426d3f1f384c9bab39ab34f51b32631..4f851ce965eadc631ff5fca1d2f789fedfbb7948 100644 (file)
@@ -48,7 +48,6 @@
 #include <signal.h>
 #include <string.h>
 #include <ctype.h>
-#include <sys/param.h>
 #include <sys/sysctl.h>
 #include <sys/proc.h>
 #include <libproc.h>
@@ -2002,10 +2001,10 @@ darwin_pid_to_exec_file (int pid)
   char *path;
   int res;
 
-  path = xmalloc (MAXPATHLEN);
+  path = xmalloc (PATH_MAX);
   make_cleanup (xfree, path);
 
-  res = proc_pidinfo (pid, PROC_PIDPATHINFO, 0, path, MAXPATHLEN);
+  res = proc_pidinfo (pid, PROC_PIDPATHINFO, 0, path, PATH_MAX);
   if (res >= 0)
     return path;
   else
index f90ca9da57cf2ae3726125d0dfa8c6a0c3a740af..f014976ea6d954cf9af6e428d19d6a86a51e3316 100644 (file)
 #endif
 
 #include <unistd.h>
+
+/* For gnulib's PATH_MAX.  */
+#include "pathmax.h"
+
 #include <fcntl.h>
 
 /* First include ansidecl.h so we can use the various macro definitions
index be7db1d01b2940b18570fbfa072afa6bf6026cbd..6a362dafa59a9df9e2ebc076686367fab2f2f4cc 100644 (file)
@@ -39,7 +39,7 @@
 char *
 fbsd_pid_to_exec_file (int pid)
 {
-  size_t len = MAXPATHLEN;
+  size_t len = PATH_MAX;
   char *buf = xcalloc (len, sizeof (char));
   char *path;
 
@@ -55,7 +55,7 @@ fbsd_pid_to_exec_file (int pid)
 #endif
 
   path = xstrprintf ("/proc/%d/file", pid);
-  if (readlink (path, buf, MAXPATHLEN - 1) == -1)
+  if (readlink (path, buf, PATH_MAX - 1) == -1)
     {
       xfree (buf);
       buf = NULL;
index 11ae9f3c2ed57f8bc7381562267df77d121f31f9..4e7fe00585937f3a5d8fbf6c13cf6ca664007882 100644 (file)
@@ -1,3 +1,12 @@
+2013-07-01  Pedro Alves  <palves@redhat.com>
+
+       * server.h: Include "pathmax.h".
+       * linux-low.c: Don't include sys/param.h.
+       (linux_pid_exe_is_elf_64_file): Use PATH_MAX instead of
+       MAXPATHLEN.
+       * win32-low.c: Don't include sys/param.h.
+       (win32_create_inferior): Use PATH_MAX instead of MAXPATHLEN.
+
 2013-07-01  Pedro Alves  <palves@redhat.com>
 
        * event-loop.c: Don't check HAVE_UNISTD_H before including
index bb7298a4da37ce60354f157e7293e106a9cde370..47ea76d19fcb230632b7e83ca74701ef789be18b 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "gdb_wait.h"
 #include <stdio.h>
-#include <sys/param.h>
 #include <sys/ptrace.h>
 #include "linux-ptrace.h"
 #include "linux-procfs.h"
@@ -342,7 +341,7 @@ elf_64_file_p (const char *file, unsigned int *machine)
 int
 linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine)
 {
-  char file[MAXPATHLEN];
+  char file[PATH_MAX];
 
   sprintf (file, "/proc/%d/exe", pid);
   return elf_64_file_p (file, machine);
index c68c6515c08a016683cd59b9db8a6504c6bcdbf0..1a1d9b26132c73a0b1bd23be0204a8b03da6f268 100644 (file)
@@ -38,6 +38,9 @@
 #endif
 #include <setjmp.h>
 
+/* For gnulib's PATH_MAX.  */
+#include "pathmax.h"
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
index d1caa73096016d5eeb3cc8d063bdd0a165241812..30fd1e74e91891925a5a191e6639fd931c0a6769 100644 (file)
@@ -32,7 +32,6 @@
 #include <imagehlp.h>
 #include <tlhelp32.h>
 #include <psapi.h>
-#include <sys/param.h>
 #include <process.h>
 
 #ifndef USE_WIN32API
@@ -515,7 +514,7 @@ static int
 win32_create_inferior (char *program, char **program_args)
 {
 #ifndef USE_WIN32API
-  char real_path[MAXPATHLEN];
+  char real_path[PATH_MAX];
   char *orig_path, *new_path, *path_ptr;
 #endif
   BOOL ret;
@@ -546,8 +545,7 @@ win32_create_inferior (char *program, char **program_args)
       cygwin_conv_path_list (CCP_POSIX_TO_WIN_A, path_ptr, new_path, size);
       setenv ("PATH", new_path, 1);
      }
-  cygwin_conv_path (CCP_POSIX_TO_WIN_A, program, real_path,
-                   MAXPATHLEN);
+  cygwin_conv_path (CCP_POSIX_TO_WIN_A, program, real_path, PATH_MAX);
   program = real_path;
 #endif
 
index aef79da71e39fa47bcee048ebec59864769804db..f214b64c6172d697ec56bab85bd08e8e192a726b 100644 (file)
@@ -22,7 +22,6 @@
 #include "regcache.h"
 #include "target.h"
 
-#include <sys/param.h>
 #include <sys/sysctl.h>
 #include <machine/frame.h>
 #include <machine/pcb.h>
index 15d861302bffc3e779492673a77394b48bca85bf..f5992bb1f1615e18301c73d44a6210401a9edcdf 100644 (file)
@@ -32,9 +32,6 @@
 #include "gdb_wait.h"
 #include "filestuff.h"
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>         /* for MAXPATHLEN */
-#endif
 #include <sys/types.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -344,9 +341,9 @@ static char *
 inf_child_fileio_readlink (const char *filename, int *target_errno)
 {
   /* We support readlink only on systems that also provide a compile-time
-     maximum path length (MAXPATHLEN), at least for now.  */
-#if defined (HAVE_READLINK) && defined (MAXPATHLEN)
-  char buf[MAXPATHLEN - 1];
+     maximum path length (PATH_MAX), at least for now.  */
+#if defined (HAVE_READLINK) && defined (PATH_MAX)
+  char buf[PATH_MAX];
   int len;
   char *ret;
 
index cb5705032b6152cc47087475818acb17997d575c..4100cb13f66e2274d52674b2288811b46cca974b 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <sys/ptrace.h>
 #include "gdb_wait.h"
-#include <sys/param.h>
 #include "gdb_dirent.h"
 #include <ctype.h>
 
@@ -269,7 +268,7 @@ fork_load_infrun_state (struct fork_info *fp)
 static void
 fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
 {
-  char path[MAXPATHLEN];
+  char path[PATH_MAX];
   struct dirent *de;
   DIR *d;
 
@@ -283,7 +282,7 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
     {
       /* Now save the 'state' (file position) of all open file descriptors.
         Unfortunately fork does not take care of that for us...  */
-      snprintf (path, MAXPATHLEN, "/proc/%ld/fd", (long) PIDGET (fp->ptid));
+      snprintf (path, PATH_MAX, "/proc/%ld/fd", (long) PIDGET (fp->ptid));
       if ((d = opendir (path)) != NULL)
        {
          long tmp;
index 6ba71bacce410b1091e8e9628e6aa1d912245572..45a6e5f278ca1271845897e0fa29fe5fa6f1ed06 100644 (file)
@@ -39,7 +39,6 @@
 #include "inf-child.h"
 #include "inf-ptrace.h"
 #include "auxv.h"
-#include <sys/param.h>         /* for MAXPATHLEN */
 #include <sys/procfs.h>                /* for elf_gregset etc.  */
 #include "elf-bfd.h"           /* for elfcore_write_* */
 #include "gregset.h"           /* for gregset */
@@ -4306,14 +4305,14 @@ linux_child_pid_to_exec_file (int pid)
 {
   char *name1, *name2;
 
-  name1 = xmalloc (MAXPATHLEN);
-  name2 = xmalloc (MAXPATHLEN);
+  name1 = xmalloc (PATH_MAX);
+  name2 = xmalloc (PATH_MAX);
   make_cleanup (xfree, name1);
   make_cleanup (xfree, name2);
-  memset (name2, 0, MAXPATHLEN);
+  memset (name2, 0, PATH_MAX);
 
   sprintf (name1, "/proc/%d/exe", pid);
-  if (readlink (name1, name2, MAXPATHLEN - 1) > 0)
+  if (readlink (name1, name2, PATH_MAX - 1) > 0)
     return name2;
   else
     return name1;
@@ -4562,7 +4561,7 @@ linux_proc_pending_signals (int pid, sigset_t *pending,
                            sigset_t *blocked, sigset_t *ignored)
 {
   FILE *procfile;
-  char buffer[MAXPATHLEN], fname[MAXPATHLEN];
+  char buffer[PATH_MAX], fname[PATH_MAX];
   struct cleanup *cleanup;
 
   sigemptyset (pending);
@@ -4574,7 +4573,7 @@ linux_proc_pending_signals (int pid, sigset_t *pending,
     error (_("Could not open %s"), fname);
   cleanup = make_cleanup_fclose (procfile);
 
-  while (fgets (buffer, MAXPATHLEN, procfile) != NULL)
+  while (fgets (buffer, PATH_MAX, procfile) != NULL)
     {
       /* Normal queued signals are on the SigPnd line in the status
         file.  However, 2.6 kernels also have a "shared" pending
index 11e8f250aa7e5062248136e8613d771fced5e2d7..5e30ad20c78b0fc58612e95d48f58d0d9dd58bfe 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "m68k-tdep.h"
 
-#include <sys/param.h>
 #include <sys/dir.h>
 #include <signal.h>
 #include <sys/ptrace.h>
index 274ef435b85e544490c227746279d58c22d43850..324efd8a8f8f86141268e112da110ba232b5013c 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "defs.h"
 
-#include <sys/param.h>
-
 #include "nbsd-nat.h"
 
 /* Return the name of a file that can be opened to get the symbols for
 char *
 nbsd_pid_to_exec_file (int pid)
 {
-  size_t len = MAXPATHLEN;
+  size_t len = PATH_MAX;
   char *buf = xcalloc (len, sizeof (char));
   char *path;
 
   path = xstrprintf ("/proc/%d/exe", pid);
-  if (readlink (path, buf, MAXPATHLEN - 1) == -1)
+  if (readlink (path, buf, PATH_MAX - 1) == -1)
     {
       xfree (buf);
       buf = NULL;
index 1ff00a6d04e6251eb5206b0d5b041be297d543be..65d4f4aff92d68f0044b03ce97e37f7f285fc275 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <stdint.h>
 #include <sys/types.h>
-#include <sys/param.h>
 #include <signal.h>
 #include <sys/user.h>
 #include <sys/ioctl.h>
index 1b600f0fb5e0d957b3aa7cd3d2a98e0dfa0b899c..676961815413141a9a85b541fe62bb16347b2aae 100644 (file)
@@ -41,7 +41,6 @@
 #include <sys/ptrace.h>
 #include <sys/reg.h>
 
-#include <sys/param.h>
 #include <sys/dir.h>
 #include <sys/user.h>
 #include <signal.h>
index 0a92904d311b267e2397373a8e4334ff3212dac7..98fad072e2e81476f6e8efb6d0013ba55b80bd20 100644 (file)
@@ -189,7 +189,7 @@ ia64_hpux_handle_load_event (struct regcache *regcache)
   CORE_ADDR module_desc_addr;
   ULONGEST module_desc_size;
   CORE_ADDR so_path_addr;
-  char so_path[MAXPATHLEN];
+  char so_path[PATH_MAX];
   struct load_module_desc module_desc;
   struct so_list *new_so;
 
@@ -210,7 +210,7 @@ ia64_hpux_handle_load_event (struct regcache *regcache)
              sizeof (struct load_module_desc),
             pulongest (module_desc_size));
 
-  read_memory_string (so_path_addr, so_path, MAXPATHLEN);
+  read_memory_string (so_path_addr, so_path, PATH_MAX);
   read_memory (module_desc_addr, (gdb_byte *) &module_desc,
               sizeof (module_desc));
 
index 5863fc2689b1646307cbce17033417cf7af38197..3259f8b79055bd49eb3ed4604d846baa6745b32e 100644 (file)
@@ -22,7 +22,6 @@
 #include <sys/types.h>
 #include <signal.h>
 #include "gdb_string.h"
-#include <sys/param.h>
 #include <fcntl.h>
 
 /* SunOS shared libs need the nlist structure.  */
index 1fab9da37b6c7416f66efdd6aaef62aba9d88d44..9855bac82430750012b7a7f578137ef11f383684 100644 (file)
@@ -34,7 +34,6 @@
 #include <sys/ptrace.h>
 #include <asm/ptrace.h>
 #include <sys/types.h>
-#include <sys/param.h>
 
 #include "spu-tdep.h"
 
index a2015a8401c3d099ffd993ac6ea7d142b63201b0..01212abf5ae2a0cec596d75d28b7dd7312f9cc88 100644 (file)
@@ -66,8 +66,6 @@
 
 #include "inferior.h"          /* for signed_pointer_to_address */
 
-#include <sys/param.h>         /* For MAXPATHLEN */
-
 #include "gdb_curses.h"
 
 #include "readline/readline.h"
@@ -3130,22 +3128,14 @@ gdb_realpath (const char *filename)
      path.  Use that and realpath() to canonicalize the name.  This is
      the most common case.  Note that, if there isn't a compile time
      upper bound, you want to avoid realpath() at all costs.  */
-#if defined(HAVE_REALPATH)
+#if defined (HAVE_REALPATH) && defined (PATH_MAX)
   {
-# if defined (PATH_MAX)
     char buf[PATH_MAX];
-#  define USE_REALPATH
-# elif defined (MAXPATHLEN)
-    char buf[MAXPATHLEN];
-#  define USE_REALPATH
-# endif
-# if defined (USE_REALPATH)
     const char *rp = realpath (filename, buf);
 
     if (rp == NULL)
       rp = filename;
     return xstrdup (rp);
-# endif
   }
 #endif /* HAVE_REALPATH */
 
index ed3580163e129f966ce5d2500e0996d15868e7a5..9a0241bc651900733f44bdaf5043aa7b8731ace5 100644 (file)
@@ -54,7 +54,6 @@
 #include "gdb_string.h"
 #include "gdbthread.h"
 #include "gdbcmd.h"
-#include <sys/param.h>
 #include <unistd.h>
 #include "exec.h"
 #include "solist.h"
index a9ce667000dff2a86622981be5462f5a0c94521e..afe1554710f4c652a44e6449f3d5ecd2d867c155 100644 (file)
@@ -26,7 +26,6 @@
 #include <ctype.h>
 #include "gdb_string.h"
 
-#include <sys/param.h>
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
index 2ca71440dcd1ef5e395b7fe9cf3102699afd048a..3fdaa3763fb9c8c624368e5935bc377b92cfb87f 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <stdint.h>
 #include <sys/types.h>
-#include <sys/param.h>
 #include <signal.h>
 #include <sys/user.h>
 #include <sys/ioctl.h>
This page took 0.047059 seconds and 4 git commands to generate.