Skip to content

Conversation

@Manu-sh
Copy link

@Manu-sh Manu-sh commented Oct 25, 2021

As you should know signed integer overflow is UB, apart from that I strongly suggest you enable at least the compiler warnings (-Wall and -Wextra flags), i haven't looked for any other bugs.

@Manu-sh Manu-sh changed the title fix signed integer oveflow which is UB and shutup other warnings fix signed integer oveflow which is UB and silencing other warnings Oct 25, 2021
test
*.d
base45
.idea/
Copy link
Author

Choose a reason for hiding this comment

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

nothing just prevent to push my ide folder

max_dst_len = _max_dst_len ? *_max_dst_len : src_len * 4;

for(int i = 0; i < src_len; i+=2) {
for(unsigned i = 0; i < src_len; i+=2) {
Copy link
Author

Choose a reason for hiding this comment

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

silencing warnings about different sign

src_len = strlen(src);

for(int i = 0; i < src_len; i+=3) {
for(unsigned i = 0; i < src_len; i+=3) {
Copy link
Author

Choose a reason for hiding this comment

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

silencing warnings about different sign

return -1;

if ((255 == (a = _C2I[src[i]])) || (255 == (b = _C2I[src[i+1]])))
if ((255 == (a = _C2I[(unsigned char)src[i]])) || (255 == (b = _C2I[(unsigned char)src[i+1]])))
Copy link
Author

Choose a reason for hiding this comment

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

unsigned integer overflow is well defined, so this cast silence other useless warnings


printf("base64(\"%s\") -> \"%s\"\n", (char*)dec, enc);
};
}
Copy link
Author

Choose a reason for hiding this comment

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

C standards doesn't allow ; after function definitions

check("2021 Digital Green Certificates for travel",
"NF6OF6P34SED-EDAECS34ZKE1$CO345$CBWER.CGPC7WE.OEX.CBJEKWEKEC: C");
};
}
Copy link
Author

Choose a reason for hiding this comment

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

C standards doesn't allow ; after function definitions

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