Module Name: src Committed By: tron Date: Sun Oct 24 17:44:32 UTC 2010
Modified Files: src/lib/libc/stdio: ftell.c local.h Log Message: Replace _FPOS_OVERFLOW() macro with a static inline function called __fpos_overflow() that doesn't cause any lint warnings. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libc/stdio/ftell.c cvs rdiff -u -r1.28 -r1.29 src/lib/libc/stdio/local.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdio/ftell.c diff -u src/lib/libc/stdio/ftell.c:1.16 src/lib/libc/stdio/ftell.c:1.17 --- src/lib/libc/stdio/ftell.c:1.16 Fri Oct 22 21:29:45 2010 +++ src/lib/libc/stdio/ftell.c Sun Oct 24 17:44:32 2010 @@ -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; } Index: src/lib/libc/stdio/local.h diff -u src/lib/libc/stdio/local.h:1.28 src/lib/libc/stdio/local.h:1.29 --- src/lib/libc/stdio/local.h:1.28 Sat Oct 23 14:12:50 2010 +++ src/lib/libc/stdio/local.h Sun Oct 24 17:44:32 2010 @@ -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); +}