Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag

Michael Paquier <[email protected]>
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
On Mon, Dec 09, 2019 at 08:49:26AM +0500, Andrey Lepikhov wrote:
> xact.c: In function ‘RecordTransactionAbort’:
> xact.c:5709:55: warning: argument 1 null where non-null expected [-Wnonnull]
>     XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid)
> + 1);

    Assert(twophase_gid != NULL);
-
-   if (XLogLogicalInfoActive())
-       xl_xinfo.xinfo |= XACT_XINFO_HAS_GID;
	    
xlinfo is set in the first part logging the transaction commit and the
record data is registered in the second, so I think that the original
coding makes more sense than what you are suggesting.  Perhaps it
would help to just add an assertion on twophase_gid to make sure that
it is not NULL in the part registering the data?  After that we really
have no bugs here, so it does not really help much..

> formatting.c: In function ‘parse_datetime’:
> formatting.c:4229:13: warning: ‘flags’ may be used uninitialized in this
> function [-Wmaybe-uninitialized]
>    if (flags & DCH_ZONED)

-   uint32      flags;
+   uint32      flags = 0;

    do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error);

For this one, OK.  Wouldn't it be better to initialize flags, fprec
and have_error directly in do_to_timestamp if they are not NULL?  This
way future callers of the routine, if any, won't miss the
initialization.

By the way, are you using more specific CFLAGS to see that?  With -O3
and -Wnonnull I cannot spot both issues with GCC 9.2.1.
--
Michael
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl3t/8QACgkQnvQgOdby
QH3vSw//SaP/bmRDA5IsQs+X46aTwU0A/rsQLyIBDNlaHb/fvDs6YG+TUsP7KiWL
flWvf17RXGCIf2qU8s8Cjmpy+TqNDDWgtSKcTs0+yC6Q8PmIdBim4mJnKJBRHOaZ
GWr/82MCqMtaU3OZQkSYuuEt3L/y86zxELzh1QAZVrQ1XuKlgSkyI/z61W59pUsE
S1Zi6pF6bDBf+ldsQGMCkZG7Zzs00mpyoO92ByzVMFf85/z5uLqe4bKCm0+xSmKa
0ZDvMlS5i7SvjfMKNujGxFK7HaQ5DMO+PwH/zjGAvvtv/36+x3XM14/ofbojkKIm
2+8VuNt6en0Hhnh9C+KAALeVTC6Irae6zUPVd3JNxlDeMCnEO3ks7GMuzwUkiNDl
hVbz/CcmA34hFU8oxm9Z89tGv2OfWkNmBQda6LooT94gvhfRFzGAfnkq+/F4Vq8L
2Z9M0ZVggz2GVQvhHT2E2HG0k52ITrUhyPqleqwCIUA/Sg4BTX/28sHbZVn+m0VS
9N6D3YNSOHqAFFj178cpMyKy37zWUMwhfcrwwaqSJMRB6JVSWyJeOG/yF63rYdiY
whKQRFrA7qWl9AdQqcAbEfgCxvffQaBHFwqQtXey+gYWC64vmUy13knlrDFTUfki
acrm+5fopgtwH8cvnC+97khOsXPf/U0N66rY7UXUAnrAykaAir0=
=GY5f
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.