X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fopen-safer.c;h=3b36471f2373bb47973c280915769af4ee5b5071;hb=5432287a033855c8c7a36f3aa055e0db60fb3383;hp=ce493d5e3151c9c88f9a59877961a53f61465ca0;hpb=57fdfd3f8ec62b105c53bcdf6f127c35c7fe7391;p=gnulib.git diff --git a/lib/open-safer.c b/lib/open-safer.c index ce493d5e3..3b36471f2 100644 --- a/lib/open-safer.c +++ b/lib/open-safer.c @@ -1,6 +1,6 @@ /* Invoke open, but avoid some glitches. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,12 +35,9 @@ open_safer (char const *file, int flags, ...) va_list ap; va_start (ap, flags); - /* Assume mode_t promotes to int if and only if it is smaller. - This assumption isn't guaranteed by the C standard, but we - don't know of any real-world counterexamples. */ - mode = (sizeof (mode_t) < sizeof (int) - ? va_arg (ap, int) - : va_arg (ap, mode_t)); + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (ap, PROMOTED_MODE_T); va_end (ap); }