silence GCC4 warning - Mailing list pgsql-patches

From Neil Conway
Subject silence GCC4 warning
Date
Msg-id 42C8EA96.7010503@samurai.com
Whole thread Raw
Responses Re: silence GCC4 warning
List pgsql-patches
This patch silences a GCC 4.0 warning about a potentially-uninitialized
variable in pl_comp.c, and makes some minor associated cleanups. Barring
any objections I'll apply this to HEAD tomorrow.

-Neil
Index: src/pl/plpgsql/src/pl_comp.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/pl/plpgsql/src/pl_comp.c,v
retrieving revision 1.91
diff -c -r1.91 pl_comp.c
*** src/pl/plpgsql/src/pl_comp.c    10 Jun 2005 16:23:11 -0000    1.91
--- src/pl/plpgsql/src/pl_comp.c    4 Jul 2005 07:48:09 -0000
***************
*** 1369,1375 ****
      HeapTuple    attrtup = NULL;
      Form_pg_attribute attrStruct;
      HeapTuple    typetup = NULL;
!     char       *cp[2];
      char       *colname[1];
      int            qualified_att_len;
      int            numdots = 0;
--- 1369,1375 ----
      HeapTuple    attrtup = NULL;
      Form_pg_attribute attrStruct;
      HeapTuple    typetup = NULL;
!     char       *cp[2] = {NULL, NULL};
      char       *colname[1];
      int            qualified_att_len;
      int            numdots = 0;
***************
*** 1389,1410 ****
      {
          if (word[i] == '.' && ++numdots == 2)
          {
!             cp[0] = (char *) palloc((i + 1) * sizeof(char));
!             memset(cp[0], 0, (i + 1) * sizeof(char));
              memcpy(cp[0], word, i * sizeof(char));

              /*
               * qualified_att_len - one based position + 1 (null
               * terminator)
               */
!             cp[1] = (char *) palloc((qualified_att_len - i) * sizeof(char));
!             memset(cp[1], 0, (qualified_att_len - i) * sizeof(char));
              memcpy(cp[1], &word[i + 1], (qualified_att_len - i - 1) * sizeof(char));

              break;
          }
      }

      relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0], "plpgsql_parse_tripwordtype"));
      classOid = RangeVarGetRelid(relvar, true);
      if (!OidIsValid(classOid))
--- 1389,1411 ----
      {
          if (word[i] == '.' && ++numdots == 2)
          {
!             cp[0] = (char *) palloc0((i + 1) * sizeof(char));
              memcpy(cp[0], word, i * sizeof(char));

              /*
               * qualified_att_len - one based position + 1 (null
               * terminator)
               */
!             cp[1] = (char *) palloc0((qualified_att_len - i) * sizeof(char));
              memcpy(cp[1], &word[i + 1], (qualified_att_len - i - 1) * sizeof(char));

              break;
          }
      }

+     /* We must have found a match */
+     Assert(i < qualified_att_len);
+
      relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0], "plpgsql_parse_tripwordtype"));
      classOid = RangeVarGetRelid(relvar, true);
      if (!OidIsValid(classOid))

pgsql-patches by date:

Previous
From: "Dave Page"
Date:
Subject: Re: [HACKERS] Dbsize backend integration
Next
From: Marko Kreen
Date:
Subject: Re: contrib/pgcrypto patch for OpenSSL 0.9.8