]> granicus.if.org Git - postgresql/commitdiff
Silence uninitialized variable compiler warning in sepgsql
authorJoe Conway <mail@joeconway.com>
Thu, 6 Apr 2017 21:28:19 +0000 (14:28 -0700)
committerJoe Conway <mail@joeconway.com>
Thu, 6 Apr 2017 21:28:19 +0000 (14:28 -0700)
At -Og optimization gcc warns that variable tclass may be used
uninitialized when relkind == RELKIND_INDEX. Actually that can't
happen due to an early return, but quiet the compiler by initializing
tclass to 0.

In passing, use uint16_t consistently for the declaration of tclass.

Complaint and initial patch by Mike Palmiotto. Editorializing by me.
Probably not worth backpatching given that it is cosmetic, so apply
to development head only.

Discussion: https://postgr.es/m/flat/623bcaae-112e-ced0-8c22-a84f75ae0c53%40joeconway.com

contrib/sepgsql/relation.c

index ab98a9b4f235ecb9c42d53de99c787747c33dd2f..2ea6bfb7d37e2a33bdcb13cc98f6d54edd9787bb 100644 (file)
@@ -243,7 +243,7 @@ sepgsql_relation_post_create(Oid relOid)
        HeapTuple       tuple;
        Form_pg_class classForm;
        ObjectAddress object;
-       uint16          tclass;
+       uint16_t        tclass;
        char       *scontext;           /* subject */
        char       *tcontext;           /* schema */
        char       *rcontext;           /* relation */
@@ -413,7 +413,7 @@ sepgsql_relation_drop(Oid relOid)
 {
        ObjectAddress object;
        char       *audit_name;
-       uint16_t        tclass;
+       uint16_t        tclass = 0;
        char            relkind;
 
        relkind = get_rel_relkind(relOid);