Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #4 - Silence uninitialized warnings #5

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Conversation

demerphq
Copy link
Contributor

Since cost is not initialized and the compiler cannot tell
if they are properly initialized (they are) warnings are produced
when building in blead perl under certain compilers.

This patch silences the warnings by making sure the data structures
are initialized to 0.

Warnings silenced:

gcc -c  -I. -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O3   -DVERSION=\"2.101\" -DXS_VERSION=\"2.101\" -fPIC "-I../.."  -Wall -Wno-comment  -DBZ_NO_STDIO  compress.c
compress.c: In function ‘BZ2_compressBlock’:
compress.c:392:54: warning: ‘cost[5]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
	    for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
						  ^~
compress.c:256:11: note: ‘cost[5]’ was declared here
UInt16 cost[BZ_N_GROUPS];
       ^~~~
compress.c:402:21: warning: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
	 if (cost[t] < bc) { bc = cost[t]; bt = t; };
	     ~~~~^~~
compress.c:256:11: note: ‘cost[3]’ was declared here
UInt16 cost[BZ_N_GROUPS];
       ^~~~
compress.c:402:21: warning: ‘cost[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
	 if (cost[t] < bc) { bc = cost[t]; bt = t; };
	     ~~~~^~~
compress.c:256:11: note: ‘cost[2]’ was declared here
UInt16 cost[BZ_N_GROUPS];
       ^~~~

Since cost is not initialized and the compiler cannot tell
if they are properly initialized (they are) warnings are produced
when building in blead perl under certain compilers.

This patch silences the warnings by making sure the data structures
are initialized to 0.

Warnings silenced:

    gcc -c  -I. -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O3   -DVERSION=\"2.101\" -DXS_VERSION=\"2.101\" -fPIC "-I../.."  -Wall -Wno-comment  -DBZ_NO_STDIO  compress.c
    compress.c: In function ‘BZ2_compressBlock’:
    compress.c:392:54: warning: ‘cost[5]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
		    for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
							  ^~
    compress.c:256:11: note: ‘cost[5]’ was declared here
	UInt16 cost[BZ_N_GROUPS];
	       ^~~~
    compress.c:402:21: warning: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
		 if (cost[t] < bc) { bc = cost[t]; bt = t; };
		     ~~~~^~~
    compress.c:256:11: note: ‘cost[3]’ was declared here
	UInt16 cost[BZ_N_GROUPS];
	       ^~~~
    compress.c:402:21: warning: ‘cost[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
		 if (cost[t] < bc) { bc = cost[t]; bt = t; };
		     ~~~~^~~
    compress.c:256:11: note: ‘cost[2]’ was declared here
	UInt16 cost[BZ_N_GROUPS];
	       ^~~~
@demerphq
Copy link
Contributor Author

I have filed a ticket with the upstream library maintainer

https://sourceware.org/bugzilla/show_bug.cgi?id=28904

@pmqs pmqs merged commit ff3d907 into pmqs:master Feb 19, 2022
jkeenan pushed a commit to Perl/perl5 that referenced this pull request Apr 6, 2022
This commit synchs into blead versions 2.103 for 3 CPAN distributions:

Compress-Raw-Zlib
IO-Compress
Compress-Raw-Bzip2

Applying the commits one at a time would have resulted in one test
failure in one of those commits, but applying all three has all tests
passing as expected

From Changes for Compress-Raw-Zlib

2.103 3 April 2022

* Sync upstream fix for CVE-2018-25032
  GHSA-jc36-42cf-vqwj

  Update to Zlib 1.2.12
  d507f527768f6cbab5831ed3ec17fe741163785c

  Fix for inflateSync return code change
  f47ea5f36c40fe19efe404dd75fd790b115de596

  Fix for incorrect CRC from zlib 1.2.12.1
  madler/zlib@ec3df00
  60104e3a162a116548303861ae0811fb850e65fd

* AUTHOR doesn't contain the stated information
  bf5a03c1b440c8d9e41cffb344bf889794cc532b

From Changes for IO-Compress

2.103 3 April 2022

* Update version to 2.103
  97f1893892eccac69b3a8033378b0b44d7c4f3ab

* Fix for inflateSyncs retrurn code change
  4843e22285bf8e52c9b5b913d167a1545995c793

* Add constant for ZIP_CM_AES
  91be04dd8dc2848e3c25b87ec498cf8ccc34187a

* Point links to rfcs to ietf.org
  pmqs/IO-Compress#37
  a8f28b36cf4d77df1cfa0516867012425920a62f

* Rename test file to fix manifest warning
  pmqs/IO-Compress#36
  955244f9ac0654d7e8d54115162da53c85d7178c

* Add perl 5.34
  06f41883f62ed1b88b03c246b16e0b5ef72503bc

* Fix for Calling nextStream on an IO::Uncompress::Zip object in Transparent mode dies when input is uncompressed
  pmqs/IO-Compress#34
  b0f93fe62f84b7d4d4bb8d2ea8e6d5432887103f

* IO::Compress: Generalize for EBCDIC
  pmqs/IO-Compress#32
  90b51dbbd785e2c824cb0a93feef3b3dd5d075f2

* IO::Compress: Fix misspelling in 112utf8-zip.t
  c22216b5d3202dce01ef17a271252f82520a6ab9

* Revert "Always have full zip64 entry in central directory"
  7df4c9bc98667bc1afd1b4bc5a27d20f94e3cd9c

* Always have full zip64 entry in central directory
  333648ee1dece6eb220060c7ec09806f6ebb9866

* update cpanm path on MacOS
  33079902934885c515768a08d72e89243a5d01a9

From Changes for Compress-Raw-Bzip2

2.103 3 April 2022

* Silence uninitialized warnings
  pmqs/Compress-Raw-Bzip2#5
  ff3d907325091287ac1525db384b99a968d763d7
  641a440ec6229c1d368b9ead48f4968b955c0115
jkeenan pushed a commit to Perl/perl5 that referenced this pull request Apr 7, 2022
This commit synchs into blead versions 2.103 for 3 CPAN distributions:

Compress-Raw-Zlib
IO-Compress
Compress-Raw-Bzip2

Applying the commits one at a time would have resulted in one test
failure in one of those commits, but applying all three has all tests
passing as expected

From Changes for Compress-Raw-Zlib

2.103 3 April 2022

* Sync upstream fix for CVE-2018-25032
  GHSA-jc36-42cf-vqwj

  Update to Zlib 1.2.12
  d507f527768f6cbab5831ed3ec17fe741163785c

  Fix for inflateSync return code change
  f47ea5f36c40fe19efe404dd75fd790b115de596

  Fix for incorrect CRC from zlib 1.2.12.1
  madler/zlib@ec3df00
  60104e3a162a116548303861ae0811fb850e65fd

* AUTHOR doesn't contain the stated information
  bf5a03c1b440c8d9e41cffb344bf889794cc532b

From Changes for IO-Compress

2.103 3 April 2022

* Update version to 2.103
  97f1893892eccac69b3a8033378b0b44d7c4f3ab

* Fix for inflateSyncs retrurn code change
  4843e22285bf8e52c9b5b913d167a1545995c793

* Add constant for ZIP_CM_AES
  91be04dd8dc2848e3c25b87ec498cf8ccc34187a

* Point links to rfcs to ietf.org
  pmqs/IO-Compress#37
  a8f28b36cf4d77df1cfa0516867012425920a62f

* Rename test file to fix manifest warning
  pmqs/IO-Compress#36
  955244f9ac0654d7e8d54115162da53c85d7178c

* Add perl 5.34
  06f41883f62ed1b88b03c246b16e0b5ef72503bc

* Fix for Calling nextStream on an IO::Uncompress::Zip object in Transparent mode dies when input is uncompressed
  pmqs/IO-Compress#34
  b0f93fe62f84b7d4d4bb8d2ea8e6d5432887103f

* IO::Compress: Generalize for EBCDIC
  pmqs/IO-Compress#32
  90b51dbbd785e2c824cb0a93feef3b3dd5d075f2

* IO::Compress: Fix misspelling in 112utf8-zip.t
  c22216b5d3202dce01ef17a271252f82520a6ab9

* Revert "Always have full zip64 entry in central directory"
  7df4c9bc98667bc1afd1b4bc5a27d20f94e3cd9c

* Always have full zip64 entry in central directory
  333648ee1dece6eb220060c7ec09806f6ebb9866

* update cpanm path on MacOS
  33079902934885c515768a08d72e89243a5d01a9

From Changes for Compress-Raw-Bzip2

2.103 3 April 2022

* Silence uninitialized warnings
  pmqs/Compress-Raw-Bzip2#5
  ff3d907325091287ac1525db384b99a968d763d7
  641a440ec6229c1d368b9ead48f4968b955c0115
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Nov 2, 2022
https://metacpan.org/dist/Compress-Raw-Bzip2/changes

License-Update: Update copyright years.

2.201 25 June 2022

* 2.201
  Sat Jun 25 08:46:32 2022 +0100
  92a318bb03b85e2dcb4991f4b958fbce6ce9913f

  * Add perl 5.36
    Sun Jun 5 13:45:55 2022 +0100
    23064d78dcd14f0898aeb64ce408914dac0805a0

* 2.103 3 April 2022

  * Silence uninitialized warnings
    pmqs/Compress-Raw-Bzip2#5
    ff3d907325091287ac1525db384b99a968d763d7
    641a440ec6229c1d368b9ead48f4968b955c0115

* 2.101 20 February 2021

  * fix version numbers in meta files

* 2.100 7 January 2021

  * trim whitespace
    f5bb5c5d254f2a9ac6c6e67a5a4823d0f67e7ecb

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Nov 2, 2022
https://metacpan.org/dist/Compress-Raw-Bzip2/changes

License-Update: Update copyright years.

2.201 25 June 2022

* 2.201
  Sat Jun 25 08:46:32 2022 +0100
  92a318bb03b85e2dcb4991f4b958fbce6ce9913f

  * Add perl 5.36
    Sun Jun 5 13:45:55 2022 +0100
    23064d78dcd14f0898aeb64ce408914dac0805a0

* 2.103 3 April 2022

  * Silence uninitialized warnings
    pmqs/Compress-Raw-Bzip2#5
    ff3d907325091287ac1525db384b99a968d763d7
    641a440ec6229c1d368b9ead48f4968b955c0115

* 2.101 20 February 2021

  * fix version numbers in meta files

* 2.100 7 January 2021

  * trim whitespace
    f5bb5c5d254f2a9ac6c6e67a5a4823d0f67e7ecb

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
scottchiefbaker pushed a commit to scottchiefbaker/perl5 that referenced this pull request Nov 3, 2022
This commit synchs into blead versions 2.103 for 3 CPAN distributions:

Compress-Raw-Zlib
IO-Compress
Compress-Raw-Bzip2

Applying the commits one at a time would have resulted in one test
failure in one of those commits, but applying all three has all tests
passing as expected

From Changes for Compress-Raw-Zlib

2.103 3 April 2022

* Sync upstream fix for CVE-2018-25032
  GHSA-jc36-42cf-vqwj

  Update to Zlib 1.2.12
  d507f527768f6cbab5831ed3ec17fe741163785c

  Fix for inflateSync return code change
  f47ea5f36c40fe19efe404dd75fd790b115de596

  Fix for incorrect CRC from zlib 1.2.12.1
  madler/zlib@ec3df00
  60104e3a162a116548303861ae0811fb850e65fd

* AUTHOR doesn't contain the stated information
  bf5a03c1b440c8d9e41cffb344bf889794cc532b

From Changes for IO-Compress

2.103 3 April 2022

* Update version to 2.103
  97f1893892eccac69b3a8033378b0b44d7c4f3ab

* Fix for inflateSyncs retrurn code change
  4843e22285bf8e52c9b5b913d167a1545995c793

* Add constant for ZIP_CM_AES
  91be04dd8dc2848e3c25b87ec498cf8ccc34187a

* Point links to rfcs to ietf.org
  pmqs/IO-Compress#37
  a8f28b36cf4d77df1cfa0516867012425920a62f

* Rename test file to fix manifest warning
  pmqs/IO-Compress#36
  955244f9ac0654d7e8d54115162da53c85d7178c

* Add perl 5.34
  06f41883f62ed1b88b03c246b16e0b5ef72503bc

* Fix for Calling nextStream on an IO::Uncompress::Zip object in Transparent mode dies when input is uncompressed
  pmqs/IO-Compress#34
  b0f93fe62f84b7d4d4bb8d2ea8e6d5432887103f

* IO::Compress: Generalize for EBCDIC
  pmqs/IO-Compress#32
  90b51dbbd785e2c824cb0a93feef3b3dd5d075f2

* IO::Compress: Fix misspelling in 112utf8-zip.t
  c22216b5d3202dce01ef17a271252f82520a6ab9

* Revert "Always have full zip64 entry in central directory"
  7df4c9bc98667bc1afd1b4bc5a27d20f94e3cd9c

* Always have full zip64 entry in central directory
  333648ee1dece6eb220060c7ec09806f6ebb9866

* update cpanm path on MacOS
  33079902934885c515768a08d72e89243a5d01a9

From Changes for Compress-Raw-Bzip2

2.103 3 April 2022

* Silence uninitialized warnings
  pmqs/Compress-Raw-Bzip2#5
  ff3d907325091287ac1525db384b99a968d763d7
  641a440ec6229c1d368b9ead48f4968b955c0115
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Nov 7, 2022
https://metacpan.org/dist/Compress-Raw-Bzip2/changes

License-Update: Update copyright years.

2.201 25 June 2022

* 2.201
  Sat Jun 25 08:46:32 2022 +0100
  92a318bb03b85e2dcb4991f4b958fbce6ce9913f

  * Add perl 5.36
    Sun Jun 5 13:45:55 2022 +0100
    23064d78dcd14f0898aeb64ce408914dac0805a0

* 2.103 3 April 2022

  * Silence uninitialized warnings
    pmqs/Compress-Raw-Bzip2#5
    ff3d907325091287ac1525db384b99a968d763d7
    641a440ec6229c1d368b9ead48f4968b955c0115

* 2.101 20 February 2021

  * fix version numbers in meta files

* 2.100 7 January 2021

  * trim whitespace
    f5bb5c5d254f2a9ac6c6e67a5a4823d0f67e7ecb

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
https://metacpan.org/dist/Compress-Raw-Bzip2/changes

License-Update: Update copyright years.

2.201 25 June 2022

* 2.201
  Sat Jun 25 08:46:32 2022 +0100
  92a318bb03b85e2dcb4991f4b958fbce6ce9913f

  * Add perl 5.36
    Sun Jun 5 13:45:55 2022 +0100
    23064d78dcd14f0898aeb64ce408914dac0805a0

* 2.103 3 April 2022

  * Silence uninitialized warnings
    pmqs/Compress-Raw-Bzip2#5
    ff3d907325091287ac1525db384b99a968d763d7
    641a440ec6229c1d368b9ead48f4968b955c0115

* 2.101 20 February 2021

  * fix version numbers in meta files

* 2.100 7 January 2021

  * trim whitespace
    f5bb5c5d254f2a9ac6c6e67a5a4823d0f67e7ecb

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants