diff mbox

[libcpp] : S_ISREG non-zero value does not always fit in a bool

Message ID e054ffda51.Jo@hobbes.bass-software.com
State New
Headers show

Commit Message

John Tytgat May 29, 2011, 1:39 p.m. UTC
In libcpp/files.c the value of S_ISREG() is assigned to a bool variable.
AFAIK a non-zero value of S_ISREG does not necessary fit into a bool
(unsigned char) so on some systems the file reading is a bit less efficient
wrt its buffer size determination.

Please commit after positive review (I don't have commit write rights).

John.

2011-05-29  John Tytgat  <John.Tytgat@aaug.net>

	* files.c (read_file_guts): Add test on non-zero value of S_ISREG.

Comments

Tom Tromey June 2, 2011, 5:57 p.m. UTC | #1
>>>>> "John" == John Tytgat <John.Tytgat@aaug.net> writes:

John> 2011-05-29  John Tytgat  <John.Tytgat@aaug.net>
John> 	* files.c (read_file_guts): Add test on non-zero value of S_ISREG.

It seems reasonable enough to me.  I am checking it in.

Out of curiosity, do you know of a platform where this is an issue?

Tom
diff mbox

Patch

Index: libcpp/files.c
===================================================================
--- libcpp/files.c	(revision 174393)
+++ libcpp/files.c	(working copy)
@@ -595,7 +595,7 @@ 
       return false;
     }
 
-  regular = S_ISREG (file->st.st_mode);
+  regular = S_ISREG (file->st.st_mode) != 0;
   if (regular)
     {
       /* off_t might have a wider range than ssize_t - in other words,