Skip to content

Conversation

@hartwork
Copy link
Member

No description provided.

…-to-pointer-cast)

Symptom was:
> lv_bmp.c: In function 'load_uncompressed':
> lv_bmp.c:75:61: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>    75 |                                 uint8_t *end = (uint8_t *) ((int)data & ~1);
>       |                                                             ^
> lv_bmp.c:75:48: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    75 |                                 uint8_t *end = (uint8_t *) ((int)data & ~1);
>       |                                                ^
> lv_bmp.c:96:61: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>    96 |                                 uint8_t *end = (uint8_t *) ((int)data & ~7);
>       |                                                             ^
> lv_bmp.c:96:48: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    96 |                                 uint8_t *end = (uint8_t *) ((int)data & ~7);
>       |                                                ^
Symptom was:
> ./gettext.h:71: error: "gettext_noop" redefined [-Werror]
>    71 | #define gettext_noop(String) String
>       |
> ./gettext.h:49: note: this is the location of the previous definition
>    49 | # define gettext_noop(Msgid) ((const char *) (Msgid))
>       |
Symptom was:
> lv_bmp.c: In function 'visual_bitmap_load':
> lv_bmp.c:286:9: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   286 |         fread (magic, 2, 1, fp);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:294:9: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   294 |         fread (&bf_size, 4, 1, fp);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:301:9: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   301 |         fread (&bf_bits, 4, 1, fp);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:305:9: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   305 |         fread (&bi_size, 4, 1, fp);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:310:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   310 |                 fread (&bi_width, 2, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:311:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   311 |                 fread (&bi_height, 2, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:319:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   319 |                 fread (&bi_bitcount, 2, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:324:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   324 |                 fread (&bi_width, 4, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:325:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   325 |                 fread (&bi_height, 4, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:333:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   333 |                 fread (&bi_bitcount, 2, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:337:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   337 |                 fread (&bi_compression, 4, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lv_bmp.c:344:17: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
>   344 |                 fread (&bi_clrused, 4, 1, fp);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Symptom was:
> ../../libvisual-0.4.2/libvisual/lv_mem.c: In function 'mem_copy_altivec':
> ../../libvisual-0.4.2/libvisual/lv_mem.c:379:1: error: no return statement in function returning non-void [-Werror=return-type]
>   379 | }
>       | ^
> ../../libvisual-0.4.2/libvisual/lv_mem.c: In function 'mem_set8_altivec':
> ../../libvisual-0.4.2/libvisual/lv_mem.c:529:1: error: no return statement in function returning non-void [-Werror=return-type]
>   529 | }
>       | ^
> ../../libvisual-0.4.2/libvisual/lv_mem.c: In function 'mem_set16_altivec':
> ../../libvisual-0.4.2/libvisual/lv_mem.c:673:1: error: no return statement in function returning non-void [-Werror=return-type]
>   673 | }
>       | ^
> ../../libvisual-0.4.2/libvisual/lv_mem.c: In function 'mem_set32_altivec':
> ../../libvisual-0.4.2/libvisual/lv_mem.c:784:1: error: no return statement in function returning non-void [-Werror=return-type]
>   784 | }
>       | ^
> ../../libvisual-0.4.2/libvisual/lv_mem.c: At top level:
> ../../libvisual-0.4.2/libvisual/lv_mem.c:781:14: error: 'mem_set32_altivec' defined but not used [-Werror=unused-function]
>   781 | static void *mem_set32_altivec (void *dest, int c, visual_size_t n)
>       |              ^~~~~~~~~~~~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_mem.c:670:14: error: 'mem_set16_altivec' defined but not used [-Werror=unused-function]
>   670 | static void *mem_set16_altivec (void *dest, int c, visual_size_t n)
>       |              ^~~~~~~~~~~~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_mem.c:526:14: error: 'mem_set8_altivec' defined but not used [-Werror=unused-function]
>   526 | static void *mem_set8_altivec (void *dest, int c, visual_size_t n)
>       |              ^~~~~~~~~~~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_mem.c:376:14: error: 'mem_copy_altivec' defined but not used [-Werror=unused-function]
>   376 | static void *mem_copy_altivec (void *dest, const void *src, visual_size_t n)
>       |              ^~~~~~~~~~~~~~~~
Symptom was:
> ../../libvisual-0.4.2/libvisual/lv_video.c: In function 'visual_video_fill_color_rectangle':
> ../../libvisual-0.4.2/libvisual/lv_video.c:1766:1: error: label 'out' defined but not used [-Werror=unused-label]
>  1766 | out:
>       | ^~~
Symptom was:
> ../../libvisual-0.4.2/libvisual/lv_plugin.c: In function 'plugin_add_dir_to_list':
> ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:39: error: '%s' directive output may be truncated writing up to 1023 bytes into a region of size 1022 [-Werror=format-truncation=]
>   605 |                 snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name);
>       |                                       ^~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:43: note: format string is defined here
>   605 |                 snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name);
>       |                                           ^~
> ../../libvisual-0.4.2/libvisual/lv_plugin.c:605:17: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) into a destination of size 1023
>   605 |                 snprintf (temp, 1023, "%s/%s", dir, namelist[i]->d_name);
>       |                 ^~~~~~~~

TRUNC
Symptom was:
> ../../libvisual-0.4.2/libvisual/lv_audio.c:129:12: error: 'audio_band_energy' defined but not used [-Werror=unused-function]
>   129 | static int audio_band_energy (VisAudio *audio, int band, int length)
>       |            ^~~~~~~~~~~~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_audio.c:115:12: error: 'audio_band_total' defined but not used [-Werror=unused-function]
>   115 | static int audio_band_total (VisAudio *audio, int begin, int end)
>       |            ^~~~~~~~~~~~~~~~> ../../libvisual-0.4.2/libvisual/lv_audio.c:129:12: error: 'audio_band_energy' defined but not used [-Werror=unused-function]
>   129 | static int audio_band_energy (VisAudio *audio, int band, int length)
>       |            ^~~~~~~~~~~~~~~~~
> ../../libvisual-0.4.2/libvisual/lv_audio.c:115:12: error: 'audio_band_total' defined but not used [-Werror=unused-function]
>   115 | static int audio_band_total (VisAudio *audio, int begin, int end)
>       |            ^~~~~~~~~~~~~~~~
Symptom was:
> ../../libvisual-0.4.2/libvisual/lv_audio.c:1111:2: error: variable 'signedcorr' is uninitialized when used here [-Werror,-Wuninitialized]
>         signedcorr += byte_max_numeric (size) / 2;
>         ^~~~~~~~~~
@hartwork hartwork added the bug label Dec 23, 2024
@hartwork hartwork added this to the 0.4.3 milestone Dec 23, 2024
@hartwork hartwork requested a review from kaixiong December 23, 2024 20:29
@hartwork hartwork changed the title [0.4.x] Address some warnings [0.4.x] Address some more warnings Dec 23, 2024
@hartwork hartwork changed the title [0.4.x] Address some more warnings [0.4.x] libvisual: Address some more warnings Dec 23, 2024
/* Unpack 4 bpp pixels aka 2 pixels per byte */
uint8_t *col = data - video->pitch;
uint8_t *end = (uint8_t *) ((int)data & ~1);
uint8_t *end = (uint8_t *) ((uintptr_t)data & ~1);
Copy link
Member

@kaixiong kaixiong Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is atrocious. This arithmetic trick also depends on the memory alignment of the data pointer to be 8 bytes or more, but this assumption seems to be relatively safe.

Copy link
Member

@kaixiong kaixiong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fixes. Disgusting bugs 😱

@hartwork
Copy link
Member Author

@kaixiong thanks for the review! 🙏

@hartwork hartwork merged commit c407faa into 0.4.x Dec 24, 2024
12 checks passed
@hartwork hartwork deleted the 0.4.x-address-some-warnings branch December 24, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants