process the scanf() output so Ubuntu 22 compiler doesn't error due to…#3
Conversation
… default warn_unused_result instead of Makefile -Wunused-result
|
Why not Makefile -Wunused-result ? Seems cleaner than adding code with no functionality. |
|
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. |
|
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. |
|
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. |
… 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).