Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdio Replace _FPOS_OVERFLOW() macro with a static ...
details: https://anonhg.NetBSD.org/src/rev/4bbc6bdfc219
branches: trunk
changeset: 758178:4bbc6bdfc219
user: tron <tron%NetBSD.org@localhost>
date: Sun Oct 24 17:44:32 2010 +0000
description:
Replace _FPOS_OVERFLOW() macro with a static inline function called
__fpos_overflow() that doesn't cause any lint warnings.
diffstat:
lib/libc/stdio/ftell.c | 7 ++++---
lib/libc/stdio/local.h | 13 ++++++++++---
2 files changed, 14 insertions(+), 6 deletions(-)
diffs (59 lines):
diff -r 0962f538edb7 -r 4bbc6bdfc219 lib/libc/stdio/ftell.c
--- a/lib/libc/stdio/ftell.c Sun Oct 24 16:46:38 2010 +0000
+++ b/lib/libc/stdio/ftell.c Sun Oct 24 17:44:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ftell.c,v 1.16 2010/10/22 21:29:45 christos Exp $ */
+/* $NetBSD: ftell.c,v 1.17 2010/10/24 17:44:32 tron Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: ftell.c,v 1.16 2010/10/22 21:29:45 christos Exp $");
+__RCSID("$NetBSD: ftell.c,v 1.17 2010/10/24 17:44:32 tron Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -97,7 +97,8 @@
pos += fp->_p - fp->_bf._base;
}
FUNLOCKFILE(fp);
- if (_FPOS_OVERFLOW(pos)) {
+
+ if (__fpos_overflow(pos)) {
errno = EOVERFLOW;
return -1L;
}
diff -r 0962f538edb7 -r 4bbc6bdfc219 lib/libc/stdio/local.h
--- a/lib/libc/stdio/local.h Sun Oct 24 16:46:38 2010 +0000
+++ b/lib/libc/stdio/local.h Sun Oct 24 17:44:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: local.h,v 1.28 2010/10/23 14:12:50 christos Exp $ */
+/* $NetBSD: local.h,v 1.29 2010/10/24 17:44:32 tron Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,6 +37,9 @@
#include "wcio.h"
#include "fileext.h"
+#include <limits.h>
+#include <stdbool.h>
+
/*
* Information local to this implementation of stdio,
* in particular, macros and private variables.
@@ -117,5 +120,9 @@
/*
* Detect if the current file position fits in a long int.
*/
-#define _FPOS_OVERFLOW(pos) (/*CONSTCOND*/sizeof(fpos_t) > sizeof(long) && \
- ((pos) & (~0ULL << ((sizeof(fpos_t) - sizeof(long)) * NBBY))) != 0)
+
+static __inline bool
+__fpos_overflow(fpos_t pos)
+{
+ return (pos < LONG_MIN) || (pos > LONG_MAX);
+}
Home |
Main Index |
Thread Index |
Old Index