Skip to content

Cppcheck and GCC build warning fixes#65

Open
sshedi wants to merge 34 commits into
ecki:masterfrom
sshedi:sshedi-fixes
Open

Cppcheck and GCC build warning fixes#65
sshedi wants to merge 34 commits into
ecki:masterfrom
sshedi:sshedi-fixes

Conversation

@sshedi

@sshedi sshedi commented May 26, 2026

Copy link
Copy Markdown

This patch series addresses a bunch of items from https://github.com/ecki/net-tools/blob/master/TODO
Please let me know your feedback @ecki

@sshedi sshedi changed the title Sshedi fixes Cppcheck and GCC build warning fixes May 26, 2026
@sshedi

sshedi commented May 26, 2026

Copy link
Copy Markdown
Author

My build host details:

$ cat /etc/os-release
NAME="Fedora Linux"
VERSION="45 (Rawhide Prerelease)"
RELEASE_TYPE=development
ID=fedora
VERSION_ID=45
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 45 (Rawhide Prerelease)"

And toolchain:

$ rpm -q cppcheck gcc
cppcheck-2.20.1-1.fc45.x86_64
gcc-16.1.1-2.fc45.x86_64

@sshedi

sshedi commented Jun 9, 2026

Copy link
Copy Markdown
Author

Hi @ecki can you please take these changes?

@ecki

ecki commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Thanks for the patches, This may take a long time to review

@ecki ecki left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks mostly fine, I am not sure about the explizite breaks, but I am not up to Date with latest Linzers, so if you think they are ok, then keep them, maybe comment all with unreadhable?

I had some questions inline, can you Check, please?

Comment thread netstat.c
Comment thread rarp.c Outdated
Comment thread route.c Outdated

argv += optind;
argc -= optind;
//argc -= optind;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Isn’t getopt needing this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

By the time control reaches here, getopt is done.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Getopt is called for each Interation and I guess it uses the argc if it needs to Look at followup Parameters

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added braces around the while loop, hope this makes it better.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ah not needed i was not reading the Code Close enough, but I think we should keep einer Both or none of both, if no Arguments are processed we don’t need it on the other Hand it makes sure the global State reflect the processed options. Increasing only argv has potential for overflows

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, found a way to use argc as well.

Comment thread slattach.c
Comment thread slattach.c
Comment thread statistics.c
Comment thread statistics.c Outdated
Comment thread lib/hw.c
@sshedi

sshedi commented Jul 18, 2026

Copy link
Copy Markdown
Author

Looks mostly fine, I am not sure about the explizite breaks, but I am not up to Date with latest Linzers, so if you think they are ok, then keep them, maybe comment all with unreadhable?

I had some questions inline, can you Check, please?

Thanks a lot for spending time on this. I have addressed all of them and responded to few. Please check.

@sshedi
sshedi requested a review from ecki July 18, 2026 06:44
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
sshedi added 20 commits July 19, 2026 00:31
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
sshedi added 13 commits July 19, 2026 00:53
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
Comment thread statistics.c
if (ferror(f)) {
perror("/proc/net/sctp/snmp");
if (process_fd2(f, filename)) {
fprintf(stderr, _("%s - parse error\n"), filename);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hm, that now probably writes two Error lines

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Made the process_fd2 similar to process_fd and removed the error message print in process_fd2

Comment thread arp.c
Comment thread arp.c
Comment thread Makefile Outdated
Comment thread netstat.c Outdated
Comment thread netstat.c
Comment thread netstat.c
Comment thread rarp.c
Comment thread rarp.c Outdated
Comment thread route.c
Comment thread statistics.c Outdated

@ecki ecki left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for seeing that through, will be great if it Passes Werror!

@sshedi
sshedi force-pushed the sshedi-fixes branch 2 times, most recently from 8d6650b to 7b8870d Compare July 18, 2026 19:52
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