Skip to content

base64: fix assignment to wrong type#56

Open
mmilata wants to merge 1 commit into
rustyrussell:masterfrom
mmilata:base64fix
Open

base64: fix assignment to wrong type#56
mmilata wants to merge 1 commit into
rustyrussell:masterfrom
mmilata:base64fix

Conversation

@mmilata

@mmilata mmilata commented May 11, 2017

Copy link
Copy Markdown
Contributor

Found by gcc:

base64.c:196:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (more == -1) {
           ^

@dgibson

dgibson commented May 12, 2017 via email

Copy link
Copy Markdown
Collaborator

@peterbarker

Copy link
Copy Markdown

From program flow maximum size of the parameter is 3, so overflow is unlikely.

Changing it to return ssize_t would seem to be reasonable, 'though.

@mmilata Do you think changing the return type to ssize_t is reasonable? If so, would you like to do a PR for that?

Functions that returned int have been modified to return ssize_t
instead.

Found by gcc:

base64.c:196:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (more == -1) {
           ^

Signed-off-by: Martin Milata <martin@martinmilata.cz>
@mmilata

mmilata commented May 15, 2017

Copy link
Copy Markdown
Contributor Author

@peterbarker Updated the PR to use ssize_t. I've also changed the return type of base64_decode_quartet_using_maps for the sake of consistency. Please take a look?

@jsarenik

Copy link
Copy Markdown
Contributor

👍 @rustyrussell please merge, then ElementsProject/libwally-core@bf81e8b will need a ccan-update
(noticed today while compiling current ElementsProject/lightning@9470ea303)

@jsarenik

Copy link
Copy Markdown
Contributor

Just that it would be nicer without the warning… =)

../../../libwally-core/src/ccan/ccan/base64/base64.c: In function 'base64_decode_using_maps':
../../../libwally-core/src/ccan/ccan/base64/base64.c:196:11: warning: comparison
 of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'}
 and 'int' [-Wsign-compare]
  196 |  if (more == -1) {
      |           ^~

@rustyrussell

Copy link
Copy Markdown
Owner

Thanks, applied!

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.

5 participants