This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob] Use proper file type macros.


File types are not simple bitmasks, so the code in
remote_fileio_mode_to_target() may do the wrong thing.  Luckily
gdb_stat.h provides the proper macros to check things, even if the OS
doesn't.

Spotted by Otto Moerbeek in the OpenBSD tree.

Committed as obvious.

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* remote-fileio.c (remote_fileio_mode_to_target): Use
	S_ISREG/S_ISDIR/S_ISCHR macros instead of S_IFREG/S_IFDIR/S_IFCHR.

Index: remote-fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-fileio.c,v
retrieving revision 1.20
diff -u -p -r1.20 remote-fileio.c
--- remote-fileio.c 19 Jul 2006 06:21:23 -0000 1.20
+++ remote-fileio.c 15 Dec 2006 22:58:07 -0000
@@ -192,11 +192,11 @@ remote_fileio_mode_to_target (mode_t mod
 {
   mode_t tmode = 0;
 
-  if (mode & S_IFREG)
+  if (S_ISREG(mode))
     tmode |= FILEIO_S_IFREG;
-  if (mode & S_IFDIR)
+  if (S_ISDIR(mode))
     tmode |= FILEIO_S_IFDIR;
-  if (mode & S_IFCHR)
+  if (S_ISCHR(mode))
     tmode |= FILEIO_S_IFCHR;
   if (mode & S_IRUSR)
     tmode |= FILEIO_S_IRUSR;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]