ports/sysutils/fcron/files/patch-subs.c
Eygene Ryabinkin 4839c29cd1 sysutils/fcron: fixup default argument promotion
When mode_t is char- or short-like, it will be promoted to the pure
int when it is passed as the variable argument [1], so we should pass
'int' to the va_arg.

I had also eliminated fflush for the stream opened read-only, since
it will always fail and there is no need to flush read-only streams.

[1] http://c-faq.com/~scs/cclass/int/sx11c.html

Feature safe: yes
PR: 152304
2011-09-25 07:24:25 +00:00

28 lines
751 B
C

--- subs.c.orig 2011-07-18 17:28:21.745080904 +0400
+++ subs.c 2011-07-18 19:39:18.999087202 +0400
@@ -121,7 +121,11 @@
if (flags & O_CREAT) {
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ /* Beware: default argument promotion. */
+ if (sizeof(int) > sizeof(mode_t))
+ mode = va_arg(ap, int);
+ else
+ mode = va_arg(ap, mode_t);
va_end(ap);
}
@@ -179,7 +183,11 @@
if (flags & O_CREAT) {
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ /* Beware: default argument promotion. */
+ if (sizeof(int) > sizeof(mode_t))
+ mode = va_arg(ap, int);
+ else
+ mode = va_arg(ap, mode_t);
va_end(ap);
}