Skip to content

process the scanf() output so Ubuntu 22 compiler doesn't error due to…#3

Merged
antimatter15 merged 1 commit into
antimatter15:masterfrom
bigattichouse:master
Mar 17, 2023
Merged

process the scanf() output so Ubuntu 22 compiler doesn't error due to…#3
antimatter15 merged 1 commit into
antimatter15:masterfrom
bigattichouse:master

Conversation

@bigattichouse

Copy link
Copy Markdown

… default warn_unused_result instead of Makefile -Wunused-result

Ubuntu 22.04.2 LTS gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04) errors during compilation because of an unused result. fixed (checks for value, but ignores which the parent check ALSO does).

… default warn_unused_result instead of Makefile -Wunused-result
@anzz1

anzz1 commented Mar 16, 2023

Copy link
Copy Markdown

Why not Makefile -Wunused-result ? Seems cleaner than adding code with no functionality.

@bigattichouse

bigattichouse commented Mar 16, 2023

Copy link
Copy Markdown
Author

Ultimately, the code could be changed to replace the behavior universally with error messages... a change in the makefile is just ignoring the problem. -Wunused-result can have a lot of knock on effects for code quality later for other functions. Why put the future code at risk for one line.

@anzz1

anzz1 commented Mar 16, 2023

Copy link
Copy Markdown

I've always considered the 'unused-result' to be a non-warning, a nag. There are a lot of valid cases where you need to use a function but don't care about its' return value and making non-functional if-statements instead of just disabling the nag seems to me to do exactly the thing you're trying to avoid, worsen code quality.

@bigattichouse

bigattichouse commented Mar 16, 2023

Copy link
Copy Markdown
Author

I suppose that's fair, but in this case the parent function checks the value, then looks for this empty line. I think having this one case just for the sake of consistency would make later refactoring better - repeat the pattern.

While I guess I'd be included to agree with you, I tend to avoid modifying the compiler flags which feels a bit like turning up the radio so you can't hear your brakes squealing.

It's odd that that line is in there anyway, I wonder if it's a hack to just get it to work. Perhaps deeper testing is in order to find out why it's there.

@antimatter15 antimatter15 merged commit 2af2331 into antimatter15:master Mar 17, 2023
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.

3 participants