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]

Re: [RFC] Avoid invalid parameter warnings in C runtime function for mingw builtr GDB


>>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr> writes:

Pierre>   Once again, my insufficient C knowledge is to blame...
Pierre> Would that be correct?

Pierre> #if O_CLOEXEC
Pierre>   static int fopen_e_ever_failed = 0;
Pierre> #else
Pierre>   static int fopen_e_ever_failed = 1;
Pierre> #endif

O_CLOEXEC is unconditionally defined earlier.
But you can just write:

  /* If we provide a fake O_CLOEXEC, then don't ever try "e".  */
  static int fopen_e_ever_failed = O_CLOEXEC == 0;

Pierre>   But then the variable name is not appropriate anymore...

You can rename it if you want, but I don't really care either way.

Pierre> In fact, when I tried to read the code around that function, I
Pierre> discovered that there is already another variable called
Pierre> trust_o_cloexec

Pierre>   It seems to me that both are testing the same glibc extension,
Pierre> trust_o_cloexec as it numeric form O_CLOEXEC
Pierre> and fopen_e_ever_failed as its string mode equivalent "e".
Pierre>   Is it really possible that trust_o_cloexec and fopen_e_ever_failed
Pierre> do not match?

I forget exactly why I did this.
Maybe I was just being overly cautious.

Pierre>   Should a unique variable be enough?

Maybe.

Tom


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