This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: fix warnings for build-bounded


2000-07-11  Greg McGary  <greg@mcgary.org>

	* include/libc-symbols.h [!__ASSEMBLER__] (strong_alias):
	Add extra level of macro expansion.
	[!__ASSEMBLER__ && HAVE_WEAK_SYMBOLS] (weak_alias): nLikewise.
	* sysdeps/generic/bp-thunks.h: Ensure `struct timeval' definition
	is available at the time `select' prototype is declared.
	* sysdeps/unix/make-syscalls.sh: Remove unused variables.
	Collect non-versioned weak aliases.  Consider only non-versioned
	aliases for the user-visible systemcall name.  Do checks inline with
	call to primitive system call.
	* sysdeps/unix/sysv/linux/ptrace.c (ptrace): Add void cast to
	stand-alone bounds checks to suppress unused value warnings.
	* sysdeps/unix/sysv/linux/sysctl.c (__sysctl): Likewise.

Index: include/libc-symbols.h
===================================================================
RCS file: /cvs/glibc/libc/include/libc-symbols.h,v
retrieving revision 1.16
diff -u -p -r1.16 libc-symbols.h
--- libc-symbols.h	2000/06/27 17:05:41	1.16
+++ libc-symbols.h	2000/07/11 17:47:32
@@ -81,7 +81,8 @@
    possible, instead of embedded assembly language.  */
 
 /* Define ALIASNAME as a strong alias for NAME.  */
-# define strong_alias(name, aliasname) \
+# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
+# define _strong_alias(name, aliasname) \
   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
 
 /* This comes between the return type and function name in
@@ -93,7 +94,8 @@
 
 /* Define ALIASNAME as a weak alias for NAME.
    If weak aliases are not available, this defines a strong alias.  */
-#  define weak_alias(name, aliasname) \
+#  define weak_alias(name, aliasname) _weak_alias (name, aliasname)
+#  define _weak_alias(name, aliasname) \
   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
 
 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
Index: sysdeps/generic/bp-thunks.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/bp-thunks.h,v
retrieving revision 1.2
diff -u -p -r1.2 bp-thunks.h
--- bp-thunks.h	2000/07/06 00:48:38	1.2
+++ bp-thunks.h	2000/07/11 17:47:32
@@ -31,12 +31,19 @@
 #include <libc-symbols.h>
 #include <bp-sym.h>
 #include <bp-checks.h>
+
+/* Get `struct timeval' definition for select.  */
+#define __need_timeval
+#include <bits/time.h>
+
 #include <stddef.h>
 #include <unistd.h>
 #include <sched.h>
 #include <signal.h>
 #include <fcntl.h>
+#include <time.h>
 #include <utime.h>
+
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/klog.h>
Index: sysdeps/unix/make-syscalls.sh
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/make-syscalls.sh,v
retrieving revision 1.18
diff -u -p -r1.18 make-syscalls.sh
--- make-syscalls.sh	2000/07/08 07:12:48	1.18
+++ make-syscalls.sh	2000/07/11 17:47:32
@@ -23,14 +23,8 @@
 ptrlet='[abBfNpPs]'
 argdig='[1-9]'
 fixarg='[^vV]'$argdig	# fixed args (declare extern)
-strarg=s$argdig		# string arg (check with CHECK_STRING)
-twoarg=f$argdig		# fd pair arg (check with CHECK_N (..., 2)
-objarg=p$argdig		# object arg (check with CHECK_1)
 ptrarg=$ptrlet$argdig	# pointer arg (toss bounds)
-rtnarg='P'$argdig	# pointer return value (add bounds)
-bufarg='[bB]'$argdig	# buffer arg (check with CHECK_N)
 intarg='[inv]'$argdig	# scalar arg
-borarg='[iv]'$argdig	# boring arg (just pass it through)
 
 ##############################################################################
 
@@ -193,8 +187,14 @@ shared-only-routines += $file
   x-,-,* | x*,*.[sS],*V*) ;;
   x*,-,*$ptrlet* | x*,*.[sS],*$ptrlet*)
 
+    nv_weak=`for name in $weak; do
+		case $name in
+		*@*) ;;
+		*) echo $name;;
+	        esac; done`
+
     # choose the name with the fewest leading underscores, preferably none
-    set `echo $strong $weak |tr ' \t' '\n' |sort -r`
+    set `echo $strong $nv_weak |tr '@ \t' ' \n\n' |sort -r`
     callname=$1
 
     # convert signature string to individual numbered arg names
@@ -237,31 +237,22 @@ shared-only-routines += $file
 			-e 's/\('$ptrarg'\)/__typeof (\1v) *__unbounded/g' \
 			-e 's/\('$intarg'\)/__typeof (\1v)/g'`); \\'; \\"
 
-    # generate thunk bounds checks
-    for arg; do
-      next=$2; shift
-      case $arg in
-      B$argdig) echo "	 echo '  __ptrvalue (${arg}a) && \\'; \\" ;;
-      esac
-      case $arg in
-      n$argdig) len=$arg ;; ### save for possible use with return value.
-      $strarg) echo "	 echo '  CHECK_STRING (${arg}a); \\'; \\" ;;
-      $objarg) echo "	 echo '  CHECK_1 (${arg}a); \\'; \\" ;;
-      $twoarg) echo "	 echo '  CHECK_N (${arg}a, 2); \\'; \\" ;;
-      $bufarg)
-	case $next in
-	n$argdig) echo "	 echo '  CHECK_N (${arg}a, ${next}a); \\'; \\" ;;
-	N$argdig) echo "	 echo '  CHECK_N (${arg}a, *CHECK_1 (${next}a)); \\'; \\" ;;
-	*) echo "### BP Thunk Error: Expected length after buffer ###" ;;
-	esac ;;
-      esac
-    done
+    # stash length arg for use with mman calls that return pointers
+    len=`echo $args |sed -e 's/.*\('n$argdig'\).*/\1/'`
 
     # generate thunk epilogue
     funcall="($callname) (`echo $args | \
-		    sed -e 's/ /, /g' \
-			-e 's/\('$ptrarg'\)/__ptrvalue (\1a)/g' \
-			-e 's/\('$intarg'\)/\1a/g'`)"
+	    sed -e 's/ /, /g' \
+		-e 's/\('a$argdig'\)/__ptrvalue (\1a)/g' \
+		-e 's/\('s$argdig'\)/CHECK_STRING (\1a)/g' \
+		-e 's/\('p$argdig'\)/CHECK_1 (\1a)/g' \
+		-e 's/\('f$argdig'\)/CHECK_N (\1a, 2)/g' \
+		-e 's/\('b$argdig'\), \('n$argdig'\)/CHECK_N (\1a, \2), \2/g' \
+		-e 's/\('b$argdig'\), \('N$argdig'\)/CHECK_N (\1a, *CHECK_1 (\2a)), __ptrvalue (\2a)/g' \
+		-e 's/\('B$argdig'\), \('n$argdig'\)/CHECK_Nopt (\1a, \2), \2/g' \
+		-e 's/\('B$argdig'\), \('N$argdig'\)/CHECK_Nopt (\1a, *CHECK_1 (\2a)), __ptrvalue (\2a)/g' \
+		-e 's/\('[ivn]$argdig'\)/\1a/g'`)"
+
     case $rtn in
     P*) echo "	 echo '{ __typeof ($rtn) *__bounded rtn; \\'; \\
 	 echo '  __ptrlow (rtn) = __ptrvalue (rtn) = $funcall; \\'; \\
@@ -271,12 +262,10 @@ shared-only-routines += $file
     echo "	 echo '} \\'; \\"
 
     # generate thunk aliases
-    for name in $weak; do
-      case $name in
-	*@*) ;;
-	*) echo "	 echo 'weak_alias (BP_SYM ($strong), BP_SYM ($name)) \\'; \\" ;;
-      esac
+    for name in $nv_weak; do
+      echo "	 echo 'weak_alias (BP_SYM ($strong), BP_SYM ($name)) \\'; \\"
     done
+
     # wrap up
     echo "\
 	 echo ''; \\
Index: sysdeps/unix/sysv/linux/ptrace.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ptrace.c,v
retrieving revision 1.8
diff -u -p -r1.8 ptrace.c
--- ptrace.c	2000/07/07 02:19:05	1.8
+++ ptrace.c	2000/07/11 17:47:32
@@ -55,40 +55,40 @@ ptrace (enum __ptrace_request request, .
     case PTRACE_POKETEXT:
     case PTRACE_POKEDATA:
     case PTRACE_POKEUSER:
-      CHECK_1 ((int *) addr);
-      CHECK_1 ((int *) data);
+      (void) CHECK_1 ((int *) addr);
+      (void) CHECK_1 ((int *) data);
       break;
 
     case PTRACE_GETREGS:
     case PTRACE_SETREGS:
 #ifdef __i386__
-      CHECK_1 ((struct user_regs_struct *) data);
+      (void) CHECK_1 ((struct user_regs_struct *) data);
 #else
       /* We don't know the size of data, so the best we can do is ensure
 	 that `data' is valid for at least one word.  */
-      CHECK_1 ((int *) data);
+      (void) CHECK_1 ((int *) data);
 #endif
       break;
 
     case PTRACE_GETFPREGS:
     case PTRACE_SETFPREGS:
 #ifdef __i386__
-      CHECK_1 ((struct user_fpregs_struct *) data);
+      (void) CHECK_1 ((struct user_fpregs_struct *) data);
 #else
       /* We don't know the size of data, so the best we can do is ensure
 	 that `data' is valid for at least one word.  */
-      CHECK_1 ((int *) data);
+      (void) CHECK_1 ((int *) data);
 #endif
       break;
 
     case PTRACE_GETFPXREGS:
     case PTRACE_SETFPXREGS:
 #ifdef __i386__
-      CHECK_1 ((struct user_fpxregs_struct *) data);
+      (void) CHECK_1 ((struct user_fpxregs_struct *) data);
 #else
       /* We don't know the size of data, so the best we can do is ensure
 	 that `data' is valid for at least one word.  */
-      CHECK_1 ((int *) data);
+      (void) CHECK_1 ((int *) data);
 #endif
       break;
     };
Index: sysdeps/unix/sysv/linux/sysctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sysctl.c,v
retrieving revision 1.5
diff -u -p -r1.5 sysctl.c
--- sysctl.c	2000/07/07 02:19:05	1.5
+++ sysctl.c	2000/07/11 17:47:32
@@ -40,9 +40,9 @@ __sysctl (int *name, int nlen, void *old
     newval: newval,
     newlen: newlen
   };
-  CHECK_N (name, nlen);
-  CHECK_N (oldval, *oldlenp);
-  CHECK_N (newval, newlen);
+  (void) CHECK_N (name, nlen);
+  (void) CHECK_N (oldval, *oldlenp);
+  (void) CHECK_N (newval, newlen);
 
   return INLINE_SYSCALL (_sysctl, 1, __ptrvalue (&args));
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]