8000 Fix -Wunused-but-set-variable warning. by isbadawi · Pull Request #4 · tomas/termbox · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix -Wunused-but-set-variable warning. #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

isbadawi
Copy link
@isbadawi isbadawi commented Jan 6, 2025

Recent clang (I'm using Apple clang version 16.0.0 (clang-1600.0.26.6) that ships with macOS) fails to build with this new warning:

src/termbox.c:323:10: error: variable 'c' set but not used [-Werror,-Wunused-but-set-variable]
  323 |   int w, c = 0, l = 0;
      |          ^
1 error generated.

@isbadawi
Copy link
Author
isbadawi commented Jan 6, 2025

I just noticed another new warning, this time from gcc 13.3 from the github runner (https://github.com/isbadawi/badavi/actions/runs/12626475377/job/35179674389#step:3:97)

In function ‘decode_esc’,
    inlined from ‘read_and_extract_event’ at /home/runner/work/badavi/badavi/vendor/termbox/src/termbox.c:887:12:
/home/runner/work/badavi/badavi/vendor/termbox/src/termbox.c:862:14: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  862 |   seq[nread] = '\0';
      |   ~~~~~~~~~~~^~~~~~
/home/runner/work/badavi/badavi/vendor/termbox/src/termbox.c: In function ‘read_and_extract_event’:
/home/runner/work/badavi/badavi/vendor/termbox/src/termbox.c:794:13: note: at offset 15 into destination object ‘seq’ of size 14
  794 | static char seq[MAXSEQ];
      |             ^~~
cc1: all warnings being treated as errors

I'll take a closer look at the correct fix later, unless you'd like to take a look also.

@tomas
Copy link
Owner
tomas commented Jan 6, 2025

Hi! I wasn't aware someone else was using the library so thanks for that and the bug report. I think I stumbled into the second one you mention, but feel free to add a fix for it if needed.

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
0