]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/commitdiff
Remove compiler warnings when building Bionic.
authorDavid 'Digit' Turner <digit@google.com>
Wed, 16 Jun 2010 23:36:41 +0000 (16:36 -0700)
committerDavid 'Digit' Turner <digit@google.com>
Wed, 23 Jun 2010 00:51:41 +0000 (17:51 -0700)
Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4

33 files changed:
libc/Android.mk
libc/bionic/clearenv.c
libc/bionic/cpuacct.c
libc/bionic/fork.c
libc/bionic/fts.c
libc/bionic/pthread.c
libc/bionic/system_properties.c
libc/docs/CHANGES.TXT
libc/include/inttypes.h
libc/include/limits.h
libc/include/stdio.h
libc/include/stdlib.h
libc/include/sys/cdefs.h
libc/include/sys/select.h
libc/include/sys/types.h
libc/include/wchar.h
libc/netbsd/isc/ev_timers.c
libc/netbsd/nameser/ns_ttl.c
libc/netbsd/net/base64.c
libc/netbsd/net/getaddrinfo.c
libc/netbsd/net/getnameinfo.c
libc/private/cpuacct.h [new file with mode: 0644]
libc/regex/engine.c
libc/regex/regcomp.c
libc/regex/regerror.c
libc/regex/regexec.c
libc/stdlib/strntoumax.c
libc/tzcode/localtime.c
libc/unistd/seteuid.c
libc/unistd/setresuid.c
libc/unistd/setreuid.c
libc/unistd/setuid.c
libc/unistd/sysconf.c

index 6b2334e70460a063ebe418663cb004f2be2ad203..80c8cc7085de21e337da9f75302daf0ff036e284 100644 (file)
@@ -441,7 +441,6 @@ libc_common_cflags := \
                -D_LIBC=1                       \
                -DSOFTFLOAT                     \
                -DFLOATING_POINT                \
-               -DNEED_PSELECT=1                \
                -DINET6 \
                -I$(LOCAL_PATH)/private \
                -DUSE_DL_PREFIX \
index ffc58d9fe69d90fe474bc8f692b863a6f47e6078..0f6f066cc30e87f3819006e1923ea5dc0a1aebd8 100644 (file)
  * SUCH DAMAGE.
  */
 
+#include <stddef.h>
+
 extern char** environ;
 
 int clearenv(void)
 {
-       char **P = environ;
-       int offset;
+    char **P = environ;
 
-       for (P = &environ[offset]; *P; ++P)
-               *P = 0;
-        return 0;
+    if (P != NULL) {
+        for (; *P; ++P)
+            *P = NULL;
+    }
+    return 0;
 }
index abdbc5134cc9c0d43568d8e3e2472a5778586b35..73170739effdef51a9c1e08bca2640e3ce1f464b 100644 (file)
@@ -29,7 +29,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
-//#include <sys/types.h>
+#include "cpuacct.h"
 
 int cpuacct_add(uid_t uid)
 {
index e20f548d0bc519f54ff4775ad4ea924628b022b5..79b8fff6112599d8b6561dda250cca821c1f216e 100644 (file)
@@ -27,6 +27,7 @@
  */
 #include <unistd.h>
 #include "pthread_internal.h"
+#include "cpuacct.h"
 
 extern int  __fork(void);
 
index 3dcfb282e8b617673419f528120b64184bd42bb1..c7770b6b63b0cb83deda023391162c449f172b2c 100644 (file)
@@ -548,9 +548,9 @@ fts_build(FTS *sp, int type)
        DIR *dirp;
        void *oldaddr;
        size_t len, maxlen;
-       int nitems, cderrno, descend, level, nlinks, nostat, doadjust;
+       int nitems, cderrno, descend, level, nlinks, nostat = 0, doadjust;
        int saved_errno;
-       char *cp;
+       char *cp = NULL;
 
        /* Set current node pointer. */
        cur = sp->fts_cur;
index 8eee136b37be146db15f02652c42479b4279ea35..061cce1e8d17aca7bad1a6a366be3703cca2c3fe 100644 (file)
@@ -48,6 +48,7 @@
 #include <sys/prctl.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <stdio.h>
 
 extern int  __pthread_clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
 extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
index 5e3b9e725e24dea9ff565e01175c0f40e151d4fd..767baa3a6adae002879b6d2349284a9e9aaaedab 100644 (file)
@@ -126,7 +126,7 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
     for(;;) {
         serial = pi->serial;
         while(SERIAL_DIRTY(serial)) {
-            __futex_wait(&pi->serial, serial, 0);
+            __futex_wait((volatile void *)&pi->serial, serial, 0);
             serial = pi->serial;
         }
         len = SERIAL_VALUE_LEN(serial);
@@ -164,7 +164,7 @@ int __system_property_wait(const prop_info *pi)
     } else {
         n = pi->serial;
         do {
-            __futex_wait(&pi->serial, n, 0);
+            __futex_wait((volatile void *)&pi->serial, n, 0);
         } while(n == pi->serial);
     }
     return 0;
index 0eae752ff4efae4c48aa3ce4a7adc0f13bc7fe30..83703d8194d186746513020165bb2baa7c39fefe 100644 (file)
@@ -46,6 +46,19 @@ Differences between current and Android 2.2:
         point. We need better multi-byte support code, and wprintf/wscanf
         stuff too.
 
+- <inttypes.h>: add missing declarations for strntoimax abd strntoumax.
+
+- <stdlib.h>: add missing declarations for drand48() and erand48().
+
+- clearerr(): fix broken implementation.
+
+- Feature test macros like _POSIX_C_SOURCE / _XOPEN_SOURCE / _C99_SOURCE
+  are now handled correctly by our C library headers (see <sys/cdefs.h>)
+
+- <sys/select.h>: add missing declaration for pselect()
+
+- 
+
 -------------------------------------------------------------------------------
 Differences between Android 2.2. and Android 2.1:
 
index ca303cbc44b7435b2642d077800e61903ae33a9e..81d23152e6231b609357072da0c609500826dcde 100644 (file)
@@ -253,6 +253,9 @@ intmax_t    imaxabs(intmax_t);
 imaxdiv_t      imaxdiv(intmax_t, intmax_t);
 intmax_t       strtoimax(const char *, char **, int);
 uintmax_t      strtoumax(const char *, char **, int);
+
+intmax_t       strntoimax(const char *nptr, char **endptr, int base, size_t n);
+uintmax_t      strntoumax(const char *nptr, char **endptr, int base, size_t n);
 __END_DECLS
 
 #endif /* _INTTYPES_H_ */
index c204e4dfdd8a61496e8af7bd879f039f41db57e7..1de8ea611a976920b874c85e7f6cd57d03d92d32 100644 (file)
@@ -86,7 +86,7 @@
 #include <sys/limits.h>
 
 #if __POSIX_VISIBLE
-#include <arch/syslimits.h>
+#include <sys/syslimits.h>
 #endif
 
 #ifndef PAGESIZE
index f0e103e0f4119dc36bea33ccd05c032bf7bc49d1..d164e959b071ff9eb93a732a47e8e1a7e15c8d7f 100644 (file)
@@ -305,7 +305,7 @@ char        *cuserid(char *);
 FILE   *fdopen(int, const char *);
 int     fileno(FILE *);
 
-#if (__POSIX_VISIBLE >= 199209) || 1 /* ANDROID: Bionic does include this */
+#if (__POSIX_VISIBLE >= 199209)
 int     pclose(FILE *);
 FILE   *popen(const char *, const char *);
 #endif
index 5a991ac6fab82eaf998e00455bd9125bf07fdc7e..f88915928ed1a7184113e3f793d9cda951100e98 100644 (file)
@@ -107,6 +107,8 @@ extern long mrand48(void);
 extern long nrand48(unsigned short *);
 extern long lrand48(void);
 extern unsigned short *seed48(unsigned short*);
+extern double erand48(unsigned short xsubi[3]);
+extern double drand48(void);
 extern void srand48(long);
 extern unsigned int arc4random(void);
 extern void arc4random_stir(void);
index de1dc09092e19dfb16faa3a535bdb363aa17f39e..849e2b8c673ff4219b793150f002b68492e4b1fe 100644 (file)
 #ifndef        _SYS_CDEFS_H_
 #define        _SYS_CDEFS_H_
 
-
-/* our implementation of wchar_t is only 8-bit - die die non-portable code */
-#undef  __WCHAR_TYPE__
-#define __WCHAR_TYPE__  unsigned char
-
-
 /*
  * Macro to test if we're using a GNU C compiler of a specific vintage
  * or later, for e.g. features that appeared in a particular version
 #define        __GNUC_PREREQ__(x, y)   0
 #endif
 
-//XXX #include <machine/cdefs.h>
-
-/* BIONIC: simpler definition */
-#define __BSD_VISIBLE   1
-
 #include <sys/cdefs_elf.h>
 
 #if defined(__cplusplus)
  */
 #define        __FBSDID(s)     struct __hack
 
+/*-
+ * The following definitions are an extension of the behavior originally
+ * implemented in <sys/_posix.h>, but with a different level of granularity.
+ * POSIX.1 requires that the macros we test be defined before any standard
+ * header file is included.
+ *
+ * Here's a quick run-down of the versions:
+ *  defined(_POSIX_SOURCE)             1003.1-1988
+ *  _POSIX_C_SOURCE == 1               1003.1-1990
+ *  _POSIX_C_SOURCE == 2               1003.2-1992 C Language Binding Option
+ *  _POSIX_C_SOURCE == 199309          1003.1b-1993
+ *  _POSIX_C_SOURCE == 199506          1003.1c-1995, 1003.1i-1995,
+ *                                     and the omnibus ISO/IEC 9945-1: 1996
+ *  _POSIX_C_SOURCE == 200112          1003.1-2001
+ *  _POSIX_C_SOURCE == 200809          1003.1-2008
+ *
+ * In addition, the X/Open Portability Guide, which is now the Single UNIX
+ * Specification, defines a feature-test macro which indicates the version of
+ * that specification, and which subsumes _POSIX_C_SOURCE.
+ *
+ * Our macros begin with two underscores to avoid namespace screwage.
+ */
+
+/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
+#undef _POSIX_C_SOURCE         /* Probably illegal, but beyond caring now. */
+#define        _POSIX_C_SOURCE         199009
+#endif
+
+/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
+#undef _POSIX_C_SOURCE
+#define        _POSIX_C_SOURCE         199209
+#endif
+
+/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
+#ifdef _XOPEN_SOURCE
+#if _XOPEN_SOURCE - 0 >= 700
+#define        __XSI_VISIBLE           700
+#undef _POSIX_C_SOURCE
+#define        _POSIX_C_SOURCE         200809
+#elif _XOPEN_SOURCE - 0 >= 600
+#define        __XSI_VISIBLE           600
+#undef _POSIX_C_SOURCE
+#define        _POSIX_C_SOURCE         200112
+#elif _XOPEN_SOURCE - 0 >= 500
+#define        __XSI_VISIBLE           500
+#undef _POSIX_C_SOURCE
+#define        _POSIX_C_SOURCE         199506
+#endif
+#endif
+
+/*
+ * Deal with all versions of POSIX.  The ordering relative to the tests above is
+ * important.
+ */
+#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
+#define        _POSIX_C_SOURCE         198808
+#endif
+#ifdef _POSIX_C_SOURCE
+#if _POSIX_C_SOURCE >= 200809
+#define        __POSIX_VISIBLE         200809
+#define        __ISO_C_VISIBLE         1999
+#elif _POSIX_C_SOURCE >= 200112
+#define        __POSIX_VISIBLE         200112
+#define        __ISO_C_VISIBLE         1999
+#elif _POSIX_C_SOURCE >= 199506
+#define        __POSIX_VISIBLE         199506
+#define        __ISO_C_VISIBLE         1990
+#elif _POSIX_C_SOURCE >= 199309
+#define        __POSIX_VISIBLE         199309
+#define        __ISO_C_VISIBLE         1990
+#elif _POSIX_C_SOURCE >= 199209
+#define        __POSIX_VISIBLE         199209
+#define        __ISO_C_VISIBLE         1990
+#elif _POSIX_C_SOURCE >= 199009
+#define        __POSIX_VISIBLE         199009
+#define        __ISO_C_VISIBLE         1990
+#else
+#define        __POSIX_VISIBLE         198808
+#define        __ISO_C_VISIBLE         0
+#endif /* _POSIX_C_SOURCE */
+#else
+/*-
+ * Deal with _ANSI_SOURCE:
+ * If it is defined, and no other compilation environment is explicitly
+ * requested, then define our internal feature-test macros to zero.  This
+ * makes no difference to the preprocessor (undefined symbols in preprocessing
+ * expressions are defined to have value zero), but makes it more convenient for
+ * a test program to print out the values.
+ *
+ * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
+ * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
+ * environment (and in fact we will never get here).
+ */
+#if defined(_ANSI_SOURCE)      /* Hide almost everything. */
+#define        __POSIX_VISIBLE         0
+#define        __XSI_VISIBLE           0
+#define        __BSD_VISIBLE           0
+#define        __ISO_C_VISIBLE         1990
+#elif defined(_C99_SOURCE)     /* Localism to specify strict C99 env. */
+#define        __POSIX_VISIBLE         0
+#define        __XSI_VISIBLE           0
+#define        __BSD_VISIBLE           0
+#define        __ISO_C_VISIBLE         1999
+#else                          /* Default environment: show everything. */
+#define        __POSIX_VISIBLE         200809
+#define        __XSI_VISIBLE           700
+#define        __BSD_VISIBLE           1
+#define        __ISO_C_VISIBLE         1999
+#endif
+#endif
+
+/*
+ * Default values.
+ */
+#ifndef __XPG_VISIBLE
+# define __XPG_VISIBLE          700
+#endif
+#ifndef __POSIX_VISIBLE
+# define __POSIX_VISIBLE        200809
+#endif
+#ifndef __ISO_C_VISIBLE
+# define __ISO_C_VISIBLE        1999
+#endif
+#ifndef __BSD_VISIBLE
+# define __BSD_VISIBLE          1
+#endif
 
 #define  __BIONIC__   1
 
index 52315b99996e3a772d24e6a093a8c9864408075f..9d11ee8b5880de5212db02011cb00528459deb0f 100644 (file)
 #include <sys/cdefs.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <signal.h>
 
 __BEGIN_DECLS
 
 typedef __kernel_fd_set   fd_set;
 
 extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+extern int pselect(int n, fd_set *readfds, fd_set *writefds, fd_set *errfds,
+                   const struct timespec *timeout, const sigset_t *sigmask);
 
 __END_DECLS
 
index b071ee9127211ac6e3e86fc77b9e2ff551ed2943..33fe30e5564d3bd3b95c1f2a1b4d20b494cb6dae 100644 (file)
@@ -62,8 +62,10 @@ typedef __kernel_ino_t       ino_t;
 typedef __kernel_key_t       key_t;
 typedef __kernel_mode_t      mode_t;
 typedef __kernel_nlink_t        nlink_t;
+#ifndef _OFF_T_DEFINED_
 #define _OFF_T_DEFINED_
 typedef __kernel_off_t       off_t;
+#endif
 typedef __kernel_loff_t      loff_t;
 typedef loff_t               off64_t;  /* GLibc-specific */
 
index df456ef35e61125c1b1d474a93fbbb69a01186a4..9b744a50cd472a22646ce7bcdf2b0fdfb50445f5 100644 (file)
@@ -72,7 +72,7 @@ typedef enum {
 
 #define  WCHAR_MAX   INT_MAX
 #define  WCHAR_MIN   INT_MIN
-#define  WEOF        ((wchar_t)(-1))
+#define  WEOF        ((wint_t)(-1))
 
 extern wint_t            btowc(int);
 extern int               fwprintf(FILE *, const wchar_t *, ...);
index 9674687688876e78e6ad56722641dc848d890fc6..a584f9979d48e661d45627784a6ab67a2e4fb89f 100644 (file)
@@ -33,6 +33,7 @@ __RCSID("$NetBSD: ev_timers.c,v 1.2 2004/05/20 19:52:31 christos Exp $");
 /* Import. */
 
 #include <errno.h>
+#include <time.h>
 
 #include <isc/assertions.h>
 #include <isc/eventlib.h>
index 087819470ee87e1908876a894a70a3b81fadc6c8..cc98331f87b0e2009544352267982151ceffed4e 100644 (file)
@@ -47,7 +47,7 @@ static int    fmt1(int t, char s, char **buf, size_t *buflen);
 
 /* Macros. */
 
-#define T(x) if ((x) < 0) return (-1); else
+#define T(x) do { if ((x) < 0) return (-1); } while(0)
 
 /* Public. */
 
index 70caaf76a8f42fba91d4123a099bf4943aa7318f..72707035ff07059df61e5e32d0f886cd23a2fbc1 100644 (file)
@@ -141,7 +141,7 @@ b64_ntop(src, srclength, target, targsize)
        size_t targsize;
 {
        size_t datalength = 0;
-       u_char input[3];
+       u_char input[3] = { 0, 0, 0 };  /* make compiler happy */
        u_char output[4];
        size_t i;
 
index 51079ae963be9a9f43349caeb8ddb791d80a6dea..e7564c427f139c75c931c5d7c4113df280d35d21 100644 (file)
 #include <stdarg.h>
 #include "nsswitch.h"
 
+typedef union sockaddr_union {
+    struct sockaddr     generic;
+    struct sockaddr_in  in;
+    struct sockaddr_in6 in6;
+} sockaddr_union;
+
 #define SUCCESS 0
 #define ANY 0
 #define YES 1
@@ -349,13 +355,14 @@ _have_ipv6() {
                {{{ 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}},
                /* scope ID */
                0};
-       static const struct sockaddr *sa_test = (struct sockaddr *) &sin6_test;
+        sockaddr_union addr_test;
+        addr_test.in6 = sin6_test;
        int s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
        if (s < 0)
                return 0;
        int ret;
        do {
-               ret = connect(s, sa_test, sizeof(sin6_test));
+               ret = connect(s, &addr_test.generic, sizeof(addr_test.in6));
        } while (ret < 0 && errno == EINTR);
        int have_ipv6 = (ret == 0);
        do {
@@ -1261,7 +1268,7 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
 struct addrinfo_sort_elem {
        struct addrinfo *ai;
        int has_src_addr;
-       struct sockaddr_in6 src_addr;  /* Large enough to hold IPv4 or IPv6. */
+       sockaddr_union src_addr;
        int original_order;
 };
 
@@ -1433,11 +1440,11 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
        }
 
        /* Rule 2: Prefer matching scope. */
-       scope_src1 = _get_scope((const struct sockaddr *)&a1->src_addr);
+       scope_src1 = _get_scope(&a1->src_addr.generic);
        scope_dst1 = _get_scope(a1->ai->ai_addr);
        scope_match1 = (scope_src1 == scope_dst1);
 
-       scope_src2 = _get_scope((const struct sockaddr *)&a2->src_addr);
+       scope_src2 = _get_scope(&a2->src_addr.generic);
        scope_dst2 = _get_scope(a2->ai->ai_addr);
        scope_match2 = (scope_src2 == scope_dst2);
 
@@ -1456,11 +1463,11 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
         */
 
        /* Rule 5: Prefer matching label. */
-       label_src1 = _get_label((const struct sockaddr *)&a1->src_addr);
+       label_src1 = _get_label(&a1->src_addr.generic);
        label_dst1 = _get_label(a1->ai->ai_addr);
        label_match1 = (label_src1 == label_dst1);
 
-       label_src2 = _get_label((const struct sockaddr *)&a2->src_addr);
+       label_src2 = _get_label(&a2->src_addr.generic);
        label_dst2 = _get_label(a2->ai->ai_addr);
        label_match2 = (label_src2 == label_dst2);
 
@@ -1493,9 +1500,9 @@ _rfc3484_compare(const void *ptr1, const void* ptr2)
         */
        if (a1->has_src_addr && a1->ai->ai_addr->sa_family == AF_INET6 &&
            a2->has_src_addr && a2->ai->ai_addr->sa_family == AF_INET6) {
-               const struct sockaddr_in6 *a1_src = (const struct sockaddr_in6 *)&a1->src_addr;
+               const struct sockaddr_in6 *a1_src = &a1->src_addr.in6;
                const struct sockaddr_in6 *a1_dst = (const struct sockaddr_in6 *)a1->ai->ai_addr;
-               const struct sockaddr_in6 *a2_src = (const struct sockaddr_in6 *)&a2->src_addr;
+               const struct sockaddr_in6 *a2_src = &a2->src_addr.in6;
                const struct sockaddr_in6 *a2_dst = (const struct sockaddr_in6 *)a2->ai->ai_addr;
                prefixlen1 = _common_prefix_len(&a1_src->sin6_addr, &a1_dst->sin6_addr);
                prefixlen2 = _common_prefix_len(&a2_src->sin6_addr, &a2_dst->sin6_addr);
@@ -1600,7 +1607,7 @@ _rfc3484_sort(struct addrinfo *list_sentinel)
                elems[i].ai = cur;
                elems[i].original_order = i;
 
-               has_src_addr = _find_src_addr(cur->ai_addr, (struct sockaddr *)&elems[i].src_addr);
+               has_src_addr = _find_src_addr(cur->ai_addr, &elems[i].src_addr.generic);
                if (has_src_addr == -1) {
                        goto error;
                }
index db04fbf4623e8b8e5bc937f3098f06160e68e2f5..36664435d6ae7f2b3811edc6e348fb3b5a5afc89 100644 (file)
@@ -339,11 +339,14 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
        assert(addr != NULL);
        assert(host != NULL);
 
+       if (hostlen < 0)
+               return EAI_OVERFLOW;
+
        if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
                return EAI_SYSTEM;
 
        numaddrlen = strlen(numaddr);
-       if (numaddrlen + 1 > hostlen) /* don't forget terminator */
+       if (numaddrlen + 1 > (size_t)hostlen) /* don't forget terminator */
                return EAI_OVERFLOW;
        strlcpy(host, numaddr, hostlen);
 
@@ -356,7 +359,7 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
                    zonebuf, sizeof(zonebuf), flags);
                if (zonelen < 0)
                        return EAI_OVERFLOW;
-               if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen)
+               if ((size_t) zonelen + 1 + numaddrlen + 1 > (size_t)hostlen)
                        return EAI_OVERFLOW;
                /* construct <numeric-addr><delim><zoneid> */
                memcpy(host + numaddrlen + 1, zonebuf,
diff --git a/libc/private/cpuacct.h b/libc/private/cpuacct.h
new file mode 100644 (file)
index 0000000..8e24c8c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BIONIC_CPUACCT_H
+#define _BIONIC_CPUACCT_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+extern int cpuacct_add(uid_t uid);
+
+__END_DECLS
+
+#endif /* _BIONIC_CPUACCT_H */
index 66be3c74d16c4624b4d392ea464a69b28000c4d5..eae6ff250fa941f8a219987c4ef510a526eeb926 100644 (file)
@@ -209,7 +209,7 @@ matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[],
                        STATETEARDOWN(m);
                        return(REG_ESPACE);
                }
-               for (i = 1; i <= m->g->nsub; i++)
+               for (i = 1; i <= (int)m->g->nsub; i++)
                        m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
                if (!g->backrefs && !(m->eflags&REG_BACKR)) {
                        NOTE("dissecting");
@@ -267,8 +267,8 @@ matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[],
        }
        if (nmatch > 1) {
                assert(m->pmatch != NULL);
-               for (i = 1; i < nmatch; i++)
-                       if (i <= m->g->nsub)
+               for (i = 1; i < (ssize_t)nmatch; i++)
+                       if (i <= (int)m->g->nsub)
                                pmatch[i] = m->pmatch[i];
                        else {
                                pmatch[i].rm_so = -1;
index 5b632c8b7ddf70c6b2e8463263eafd34a397ac47..19f4790577ff5324361de349e276a901507771e7 100644 (file)
@@ -249,8 +249,8 @@ static void
 p_ere(struct parse *p, int stop)       /* character this ERE should end at */
 {
        char c;
-       sopno prevback;
-       sopno prevfwd;
+       sopno prevback = 0;
+       sopno prevfwd = 0;
        sopno conc;
        int first = 1;          /* is this the first alternative? */
 
@@ -767,7 +767,7 @@ static void
 p_b_cclass(struct parse *p, cset *cs)
 {
        char *sp = p->next;
-       struct cclass *cp;
+       const struct cclass *cp;
        size_t len;
        char *u;
        char c;
@@ -831,7 +831,7 @@ p_b_coll_elem(struct parse *p,
     int endc)                  /* name ended by endc,']' */
 {
        char *sp = p->next;
-       struct cname *cp;
+       const struct cname *cp;
        int len;
 
        while (MORE() && !SEETWO(endc, ']'))
@@ -1084,7 +1084,7 @@ freeset(struct parse *p, cset *cs)
        cset *top = &p->g->sets[p->g->ncsets];
        size_t css = (size_t)p->g->csetsize;
 
-       for (i = 0; i < css; i++)
+       for (i = 0; i < (ssize_t)css; i++)
                CHsub(cs, i);
        if (cs == top-1)        /* recover only the easy case */
                p->g->ncsets--;
@@ -1112,10 +1112,10 @@ freezeset(struct parse *p, cset *cs)
        for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
                if (cs2->hash == h && cs2 != cs) {
                        /* maybe */
-                       for (i = 0; i < css; i++)
+                       for (i = 0; i < (ssize_t)css; i++)
                                if (!!CHIN(cs2, i) != !!CHIN(cs, i))
                                        break;          /* no */
-                       if (i == css)
+                       if (i == (ssize_t)css)
                                break;                  /* yes */
                }
 
@@ -1136,7 +1136,7 @@ firstch(struct parse *p, cset *cs)
        int i;
        size_t css = (size_t)p->g->csetsize;
 
-       for (i = 0; i < css; i++)
+       for (i = 0; i < (ssize_t)css; i++)
                if (CHIN(cs, i))
                        return((char)i);
        assert(never);
@@ -1153,7 +1153,7 @@ nch(struct parse *p, cset *cs)
        size_t css = (size_t)p->g->csetsize;
        int n = 0;
 
-       for (i = 0; i < css; i++)
+       for (i = 0; i < (ssize_t)css; i++)
                if (CHIN(cs, i))
                        n++;
        return(n);
@@ -1412,7 +1412,7 @@ static void
 findmust(struct parse *p, struct re_guts *g)
 {
        sop *scan;
-       sop *start;    /* start initialized in the default case, after that */
+       sop *start = NULL;    /* start initialized in the default case, after that */
        sop *newstart; /* newstart was initialized in the OCHAR case */
        sopno newlen;
        sop s;
index 894a93931107014ba35a4950774f9f55da091c0c..838ec8f5814217582c23f1cb456364a017cb9c73 100644 (file)
@@ -78,7 +78,7 @@ static const struct rerr {
 size_t
 regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
 {
-       struct rerr *r;
+       const struct rerr *r;
        size_t len;
        int target = errcode &~ REG_ITOA;
        char *s;
@@ -117,7 +117,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
 static char *
 regatoi(const regex_t *preg, char *localbuf, int localbufsize)
 {
-       struct rerr *r;
+       const struct rerr *r;
 
        for (r = rerrs; r->code != 0; r++)
                if (strcmp(r->name, preg->re_endp) == 0)
index 7b3bfc7a0b14c40dc8e633e29f9721e46377e8b2..6feed3b83af5e3103b7aafac31925be226cc4fc9 100644 (file)
@@ -153,7 +153,7 @@ regexec(const regex_t *preg, const char *string, size_t nmatch,
                return(REG_BADPAT);
        eflags = GOODFLAGS(eflags);
 
-       if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
+       if (g->nstates <= (int)(CHAR_BIT*sizeof(states1)) && !(eflags&REG_LARGE))
                return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
        else
                return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
index a151ef50d9426c75859605a840cb47d277c91a11..050d7189381dee127df250dad604c470c63e7300 100644 (file)
@@ -48,7 +48,7 @@ static inline int digitval(int ch)
 uintmax_t
 strntoumax(const char *nptr, char **endptr, int base, size_t n)
 {
-    const unsigned char*  p   = nptr;
+    const unsigned char*  p   = (const unsigned char *)nptr;
     const unsigned char*  end = p + n;
     int                   minus = 0;
     uintmax_t             v = 0;
index 83c101162fe5315ceb2e7da4e803f2c84f202d66..85a913ea6f8549dcfd4d96c48b81ad4bf27b67af 100644 (file)
@@ -389,7 +389,11 @@ const time_t    t0;
     if (TYPE_INTEGRAL(time_t) &&
         TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
             return 0;
+#if SECSPERREPEAT_BITS <= 32  /* to avoid compiler warning (condition is always false) */
         return (t1 - t0) == SECSPERREPEAT;
+#else
+        return 0;
+#endif
 }
 
 static int toint(unsigned char *s) {
index dd9493278c7ac691dc5807994791a5545d67fabc..b3ea37273724a0533d303b7c86706e3911df8ede 100644 (file)
@@ -26,6 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <unistd.h>
+#include "cpuacct.h"
+
+extern int __setresuid(uid_t, uid_t, uid_t);
 
 int seteuid(uid_t euid)
 {
index 19648810177ee1a2efe884d770d70606035cccc8..e62b3e956ef259c9bb457f6f40b868c44db6f455 100644 (file)
@@ -26,6 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <unistd.h>
+#include "cpuacct.h"
+
+extern int __setresuid(uid_t ruid, uid_t euid, uid_t suid);
 
 int setresuid(uid_t ruid, uid_t euid, uid_t suid)
 {
index 04c28264f12a1139bd0eff7a25f2e64ddc076128..32e70c8feac6e8735021cd923fe2395d39aa258f 100644 (file)
@@ -26,6 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <unistd.h>
+#include "cpuacct.h"
+
+extern int __setreuid(uid_t ruid, uid_t euid);
 
 int setreuid(uid_t ruid, uid_t euid)
 {
index 8ab637dd6520a3020347236c00cd146828f4c010..30785d66d5946e8ba55b96f451ca5db4a99c4788 100644 (file)
@@ -26,6 +26,9 @@
  * SUCH DAMAGE.
  */
 #include <unistd.h>
+#include "cpuacct.h"
+
+extern int __setuid(uid_t);
 
 int setuid(uid_t uid)
 {
index dedc5bc17ce870ceca0c2fe014f3fa5745ff2efe..27b113c024188752647a8992937adaec4297e183 100644 (file)
@@ -96,7 +96,7 @@ sysconf( int  name )
     case _SC_COLL_WEIGHTS_MAX:  return _POSIX2_COLL_WEIGHTS_MASK;
 #endif
 #ifdef _POSIX2_EXPR_NEST_MAX
-    case _SC_EXPR_NEXT_MASK:    return _POSIX2_EXPR_NEST_MAX;
+    case _SC_EXPR_NEST_MAX:    return _POSIX2_EXPR_NEST_MAX;
 #endif
 #ifdef _POSIX2_LINE_MAX
     case _SC_LINE_MAX:          return _POSIX2_LINE_MAX;