summaryrefslogtreecommitdiff
path: root/lib/open.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-05-22 13:48:52 +0200
committerBruno Haible <bruno@clisp.org>2009-05-22 13:48:52 +0200
commit2514e7d5af226b15be3f737286b3ff8c0c91d761 (patch)
treeeedd63aebf8b8bcfc0b12a1ba51e490d88a71e5b /lib/open.c
parent3663b6b7a51eb4ccb3a3340c71b1aa8e3f51c274 (diff)
downloadgnulib-2514e7d5af226b15be3f737286b3ff8c0c91d761.tar.gz
Simplify use of mode_t varargs.
Diffstat (limited to 'lib/open.c')
-rw-r--r--lib/open.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/open.c b/lib/open.c
index 13af274602..326e6d15c0 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,5 +1,5 @@
/* Open a descriptor to a file.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 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
@@ -51,12 +51,9 @@ open (const char *filename, int flags, ...)
va_list arg;
va_start (arg, flags);
- /* If mode_t is narrower than int, use the promoted type (int),
- not mode_t. Use sizeof to guess whether mode_t is narrower;
- we don't know of any practical counterexamples. */
- mode = (sizeof (mode_t) < sizeof (int)
- ? va_arg (arg, int)
- : va_arg (arg, 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 (arg, PROMOTED_MODE_T);
va_end (arg);
}