Skip to content

Comments

fix: several compilation issues under LLVM and more#2753

Open
basilfx wants to merge 4 commits intoolikraus:masterfrom
basilfx:feature/signed_compare
Open

fix: several compilation issues under LLVM and more#2753
basilfx wants to merge 4 commits intoolikraus:masterfrom
basilfx:feature/signed_compare

Conversation

@basilfx
Copy link
Contributor

@basilfx basilfx commented Feb 15, 2026

I am upgrading the U8g2 package version in RIOT-OS. This PR fixes some of the compilation errors I encountered.

I have been able to test this against some displays and board I own. But the warnings below occur in drivers and functionality I cannot test.

Comparison of integers of mixed signs:

This fails for MSP-430 (16-bit targets). Casting rad to u8g2_int_t solves it.

u8g2_arc.c: In function 'u8g2_draw_arc':
u8g2_arc.c:78:16: error: comparison of integer expressions of different signedness: 'u8g2_int_t' {aka 'short int'} and 'unsigned int' [-Werror=sign-compare]
   78 |     else if (d < 2 * (rad - y))
      |                ^

Unused variables (LLVM):

These variables are assigned to, but never read from.

u8x8_d_st7305.c:279:12: error: variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
  uint16_t x;
           ^
u8x8_d_st7305.c:395:12: error: variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
  uint16_t x;
           ^
u8x8_d_st7305.c:609:12: error: variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
  uint16_t x;
           ^
u8x8_d_st7302.c:418:12: error: variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
  uint16_t x;
           ^

Memory alignment requirement (LLVM):

Using memcpy instead resolves this issue.

u8x8_d_sdl_128x64.c:53:13: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
   53 |       ptr = (uint32_t *)(((uint8_t *)(u8g_sdl_screen->pixels)) + offset);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Mark variable as unused (LLVM):

max_ptr is only used in assert(..), which may be a no-op if assertions are disabled. Mark it as unused resolves this.

u8g2_ll_hvline.c:79:12: error: unused variable 'max_ptr' [-Werror,-Wunused-variable]
   79 |   uint8_t *max_ptr = u8g2->tile_buf_ptr + u8g2_GetU8x8(u8g2)->display_info->tile_width*u8g2->tile_buf_height*8;
      |            ^~~~~~~
1 error

@basilfx basilfx force-pushed the feature/signed_compare branch from 674bbfb to ba6a962 Compare February 15, 2026 13:08
@basilfx basilfx changed the title fix: cast rad to u8g2_int_t in u8g2_draw_arc fix: several compilation issues under LLVM and more Feb 15, 2026
When assert(..) is a no-op, compilers may warn about the variable
being unused. Explicitly marking it to silence the warning.
@basilfx basilfx force-pushed the feature/signed_compare branch from ba6a962 to eeb416e Compare February 16, 2026 22:17
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.

1 participant