>>This is kind of silly, but building on Android produces a bunch of
>>warnings like:

>This is your compiler being an annoying busybody.

Actually, I think it is kind of a useful warning (*).  C/POSIX newbies
could well benefit from the understanding that the correct number of
arguments to pass to open() depends upon the contents (value) of the
second argument.

In fact, I've often wondered about it myself, since it is,
technically, UB to do this sort of thing - and the purists in
comp.lang.c will certainly tell you that.

Of course, we all know that as long as you're using cdecl calling
convention, it doesn't matter - and that's the beauty of the cdecl
calling convention.

(*) In general, but obviously not in the context of compiling bash.
It would, thus, be nice if this warning could be turned off as part of
the bash compilation process.

>>lib/readline/histfile.c:626:49: warning: 'open' has superfluous mode bits; 
>>missing O_CREAT or O_TMPFILE? [-Wuser-defined-warnings]
>>   626 |   file = open (filename, O_RDONLY|O_BINARY, 0666);
>>       |                                                 ^

>>It's not a big deal but it is a bit confusing to see these modes in
>>the code. Is there some platform where the mode arg is used in this
>>situation?

>That code has been there since 1991 (execpt [sic] for the cat thing) (**).
>It seems kind of silly to suddenly be worrying about it now. But I
>suppose it's necessary to quite [sic] the warnings.

It actually kind of makes you wander *why* it is there.  Surely, the
original author(s) of this code must have realized that it doesn't
make any sense to pass a mode arg if you aren't creating the file.
They obviously know whether or not they are creating the file.

(**) What "cat thing" ?

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic 
answers.
If you have nothing useful to say, then just click Next and go on.

Reply via email to