- Notifications
You must be signed in to change notification settings - Fork5k
Commitaad1617
committed
Silence uninitialized-value warnings in compareJsonbContainers().
Because not every path through JsonbIteratorNext() sets val->type,some compilers complain that compareJsonbContainers() is comparingpossibly-uninitialized values. The paths that don't set it returnWJB_DONE, WJB_END_ARRAY, or WJB_END_OBJECT, so it's clear bymanual inspection that the "(ra == rb)" code path is safe, andindeed we aren't seeing warnings about that. But the (ra != rb)case is much less obviously safe. In Assert-enabled builds itseems that the asserts rejecting WJB_END_ARRAY and WJB_END_OBJECTpersuade gcc 15.x not to warn, which makes little sense becauseit's impossible to believe that the compiler can prove of itsown accord that ra/rb aren't WJB_DONE here. (In fact they neverwill be, so the code isn't wrong, but why is there no warning?)Without Asserts, the appearance of warnings is quite unsurprising.We discussed fixing this by converting those two Asserts intopg_assume, but that seems not very satisfactory when it's so unclearwhy the compiler is or isn't warning: the warning could easilyreappear with some other compiler version. Let's fix it in a lessmagical, more future-proof way by changing JsonbIteratorNext()so that it always does set val->type. The cost of that should bepretty negligible, and it makes the function's API spec less squishy.Reported-by: Erik Rijkers <er@xs4all.nl>Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/988bf1bc-3f1f-99f3-bf98-222f1cd9dc5e@xs4all.nlDiscussion:https://postgr.es/m/0c623e8a204187b87b4736792398eaf1@postgrespro.ruBackpatch-through: 131 parent8ffd9ac commitaad1617
1 file changed
+14
-8
lines changedLines changed: 14 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
277 | 277 |
| |
278 | 278 |
| |
279 | 279 |
| |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 | 280 |
| |
284 | 281 |
| |
285 | 282 |
| |
| |||
852 | 849 |
| |
853 | 850 |
| |
854 | 851 |
| |
855 |
| - | |
856 |
| - | |
857 |
| - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
858 | 857 |
| |
859 | 858 |
| |
860 | 859 |
| |
861 | 860 |
| |
862 | 861 |
| |
| 862 | + | |
| 863 | + | |
863 | 864 |
| |
| 865 | + | |
864 | 866 |
| |
865 | 867 |
| |
866 | 868 |
| |
| |||
898 | 900 |
| |
899 | 901 |
| |
900 | 902 |
| |
| 903 | + | |
901 | 904 |
| |
902 | 905 |
| |
903 | 906 |
| |
| |||
951 | 954 |
| |
952 | 955 |
| |
953 | 956 |
| |
| 957 | + | |
954 | 958 |
| |
955 | 959 |
| |
956 | 960 |
| |
| |||
995 | 999 |
| |
996 | 1000 |
| |
997 | 1001 |
| |
998 |
| - | |
999 |
| - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
1000 | 1006 |
| |
1001 | 1007 |
| |
1002 | 1008 |
| |
|
0 commit comments
Comments
(0)