* sysdeps/posix/tempname.c (__gen_tempname): Change attempts_min
authorUlrich Drepper <drepper@redhat.com>
Fri, 7 Apr 2006 20:25:36 +0000 (20:25 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 7 Apr 2006 20:25:36 +0000 (20:25 +0000)
into a macro.  Use preprocessor to decide how to initialize
attempts [Coverity CID 67].

* io/fts.c (fts_build): Comment out dead code [Coverity CID 68].

* sunrpc/rpc_parse.c (def_union): Comment out dead code
[Coverity CID 70].

* locale/programs/linereader.c (lr_token): Remove duplicate
handling of EOF [Coverity CID 71].

* locale/programs/ld-numeric.c (numeric_read) [case tok_grouping]:
We bail out early if ignore_content is set, so there is no need to
check it later again [Coverity CID 72].

* inet/inet6_option.c (inet6_option_find): Check *tptrp for NULL,
not tptrp [Coverity CID 73].

* inet/inet6_option.c (inet6_option_next): Check *tptrp for NULL,
not tptrp [Coverity CID 74].

* misc/tsearch.c (__tsearch): Don't rotate tree if memory
allocation failed [Coverity CID 78].

ChangeLog
inet/inet6_option.c
io/fts.c
locale/programs/ld-numeric.c
locale/programs/linereader.c
misc/tsearch.c
sunrpc/rpc_parse.c
sysdeps/posix/tempname.c

index d666ae3fb220be6a24ac9a3e8baea4de92804406..e9b36e03bef5ce1454185418d08c9521eb9e8914 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2006-04-07  Ulrich Drepper  <drepper@redhat.com>
+
+       * sysdeps/posix/tempname.c (__gen_tempname): Change attempts_min
+       into a macro.  Use preprocessor to decide how to initialize
+       attempts [Coverity CID 67].
+
+       * io/fts.c (fts_build): Comment out dead code [Coverity CID 68].
+
+       * sunrpc/rpc_parse.c (def_union): Comment out dead code
+       [Coverity CID 70].
+
+       * locale/programs/linereader.c (lr_token): Remove duplicate
+       handling of EOF [Coverity CID 71].
+
+       * locale/programs/ld-numeric.c (numeric_read) [case tok_grouping]:
+       We bail out early if ignore_content is set, so there is no need to
+       check it later again [Coverity CID 72].
+
+       * inet/inet6_option.c (inet6_option_find): Check *tptrp for NULL,
+       not tptrp [Coverity CID 73].
+
+       * inet/inet6_option.c (inet6_option_next): Check *tptrp for NULL,
+       not tptrp [Coverity CID 74].
+
+       * misc/tsearch.c (__tsearch): Don't rotate tree if memory
+       allocation failed [Coverity CID 78].
+
 2006-04-07  Jakub Jelinek  <jakub@redhat.com>
 
        * sysdeps/generic/unwind-dw2.c (execute_cfa_program): Fix typo in
index 2e0fed8a30c29d7ebf99a11d0076fcf1e39ca3c8..f88982e32310021f0a94083a59521c7c63758ee2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -251,7 +251,7 @@ inet6_option_next (cmsg, tptrp)
   const uint8_t *endp = CMSG_DATA (cmsg) + (ip6e->ip6e_len + 1) * 8;
 
   const uint8_t *result;
-  if (tptrp == NULL)
+  if (*tptrp == NULL)
     /* This is the first call, return the first option if there is one.  */
     result = (const uint8_t *) (ip6e + 1);
   else
@@ -308,7 +308,7 @@ inet6_option_find (cmsg, tptrp, type)
   const uint8_t *endp = CMSG_DATA (cmsg) + (ip6e->ip6e_len + 1) * 8;
 
   const uint8_t *next;
-  if (tptrp == NULL)
+  if (*tptrp == NULL)
     /* This is the first call, return the first option if there is one.  */
     next = (const uint8_t *) (ip6e + 1);
   else
index 39c076a2c8403c6dcfe2aabeb17ad91ae631c0a4..71400d171618ae14e426e81fb9239d17fa4df97d 100644 (file)
--- a/io/fts.c
+++ b/io/fts.c
@@ -747,6 +747,10 @@ mem1:                              saved_errno = errno;
                        p->fts_flags |= FTS_ISW;
 #endif
 
+#if 0
+               /* Unreachable code.  cderrno is only ever set to a nonnull
+                  value if dirp is closed at the same time.  But then we
+                  cannot enter this loop.  */
                if (cderrno) {
                        if (nlinks) {
                                p->fts_info = FTS_NS;
@@ -754,7 +758,9 @@ mem1:                               saved_errno = errno;
                        } else
                                p->fts_info = FTS_NSOK;
                        p->fts_accpath = cur->fts_accpath;
-               } else if (nlinks == 0
+               } else
+#endif
+               if (nlinks == 0
 #if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE
                           || (nostat &&
                               dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
index a101a402f49703645653b4979873148ed76465b2..a901c4d98500b874a7724a8f644ca827ebb1960b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1999,2000,2001,2002,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2002,2005,2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -302,7 +302,7 @@ numeric_read (struct linereader *ldfile, struct localedef_t *result,
            {
              size_t act = 0;
              size_t max = 10;
-             char *grouping = ignore_content ? NULL : xmalloc (max);
+             char *grouping = xmalloc (max);
 
              do
                {
@@ -321,24 +321,20 @@ numeric_read (struct linereader *ldfile, struct localedef_t *result,
                    }
 
                  if (now->tok == tok_minus1)
-                   {
-                     if (!ignore_content)
-                       grouping[act++] = '\177';
-                   }
+                   grouping[act++] = '\177';
                  else if (now->val.num == 0)
                    {
                      /* A value of 0 disables grouping from here on but
                         we must not store a NUL character since this
                         terminates the string.  Use something different
                         which must not be used otherwise.  */
-                     if (!ignore_content)
-                       grouping[act++] = '\377';
+                     grouping[act++] = '\377';
                    }
                  else if (now->val.num > 126)
                    lr_error (ldfile, _("\
 %s: values for field `%s' must be smaller than 127"),
                              "LC_NUMERIC", "grouping");
-                 else if (!ignore_content)
+                 else
                    grouping[act++] = now->val.num;
 
                  /* Next must be semicolon.  */
@@ -353,13 +349,10 @@ numeric_read (struct linereader *ldfile, struct localedef_t *result,
              if (now->tok != tok_eol)
                goto err_label;
 
-             if (!ignore_content)
-               {
-                 grouping[act++] = '\0';
+             grouping[act++] = '\0';
 
-                 numeric->grouping = xrealloc (grouping, act);
-                 numeric->grouping_len = act;
-               }
+             numeric->grouping = xrealloc (grouping, act);
+             numeric->grouping_len = act;
            }
          break;
 
index 1d3e60f69f33c73d2f84b8df913fb37a9cb3ecaf..6587f7305bb4015ab39f8e94fe8a086cb0a45bf6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001,2002,2003,2004,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
 
@@ -214,12 +214,6 @@ lr_token (struct linereader *lr, const struct charmap_t *charmap,
        }
       while (isspace (ch));
 
-      if (ch == EOF)
-       {
-         lr->token.tok = tok_eof;
-         return &lr->token;
-       };
-
       if (ch != lr->comment_char)
        break;
 
index 7c3a0aaa78ac7fb0a5ea9680447f381c0cafcb2f..5ba244b0151193b56a26bb3e4f7b3199aaeb998b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 2000, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997.
 
@@ -285,11 +285,12 @@ __tsearch (const void *key, void **vrootp, __compar_fn_t compar)
       q->key = key;                    /* initialize new node */
       q->red = 1;
       q->left = q->right = NULL;
+
+      if (nextp != rootp)
+       /* There may be two red edges in a row now, which we must avoid by
+          rotating the tree.  */
+       maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1);
     }
-  if (nextp != rootp)
-    /* There may be two red edges in a row now, which we must avoid by
-       rotating the tree.  */
-    maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1);
 
   return q;
 }
index 9678f28140c4c8d0fce9c7248b9c7822cf1dea27..f66538701f0be241062dd2ef2ae0de5728a19c42 100644 (file)
@@ -303,7 +303,9 @@ def_union (definition *defp)
   case_list *cases;
 /*  case_list *tcase; */
   case_list **tailp;
+#if 0
   int flag;
+#endif
 
   defp->def_kind = DEF_UNION;
   scan (TOK_IDENT, &tok);
@@ -323,7 +325,9 @@ def_union (definition *defp)
       cases->case_name = tok.str;
       scan (TOK_COLON, &tok);
       /* now peek at next token */
+#if 0
       flag = 0;
+#endif
       if (peekscan (TOK_CASE, &tok))
        {
 
@@ -340,6 +344,7 @@ def_union (definition *defp)
            }
          while (peekscan (TOK_CASE, &tok));
        }
+#if 0
       else if (flag)
        {
 
@@ -347,6 +352,7 @@ def_union (definition *defp)
          tailp = &cases->next;
          cases = ALLOC (case_list);
        };
+#endif
 
       get_declaration (&dec, DEF_UNION);
       cases->case_decl = dec;
index 0d4bbc418a1da0bf8d4cbb8e9babf0c71edd1bd4..c8973a0852a7e60c483d5f186269d029815b9b0f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -242,11 +242,15 @@ __gen_tempname (char *tmpl, int kind)
      necessary to try all these combinations.  Instead if a reasonable
      number of names is tried (we define reasonable as 62**3) fail to
      give the system administrator the chance to remove the problems.  */
-  unsigned int attempts_min = 62 * 62 * 62;
+#define ATTEMPTS_MIN (62 * 62 * 62)
 
   /* The number of times to attempt to generate a temporary file.  To
      conform to POSIX, this must be no smaller than TMP_MAX.  */
-  unsigned int attempts = attempts_min < TMP_MAX ? TMP_MAX : attempts_min;
+#if ATTEMPTS_MIN < TMP_MAX
+  unsigned int attempts = TMP_MAX;
+#else
+  unsigned int attempts = ATTEMPTS_MIN;
+#endif
 
   len = strlen (tmpl);
   if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))