-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/base64: api change (const + void*) #10053
Conversation
@pwillem I agree |
unsigned char *base64_out, size_t *base64_out_size) | ||
{ | ||
const unsigned char *in = data_in; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this variable necesary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhm, right I mean thats the point of using void
right, to not hassle with casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I try to use the void. I get the following errors:
RIOT/sys/base64/base64.c: In function ‘base64_encode’:
RIOT/sys/base64/base64.c:89:28: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
tmpval = *(data_in + i);
^
RIOT/sys/base64/base64.c:89:18: error: dereferencing ‘void’ pointer [-Werror]
tmpval = *(data_in + i);
^~~~~~~~~~~~~~
RIOT/sys/base64/base64.c:89:16: error: void value not ignored as it ought to be
tmpval = *(data_in + i);
^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, void*
cannot be used in pointer arithmetic.
+1! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and the test passes.
Contribution description
This merge request changes the api of the base64 functions:
const
to input argumentsvoid *
for the raw (byte) data (input forbase64_encode()
, output forbase64_decode()
)Testing procedure
make BOARD=native -C tests/unittests tests-base64 test
still compiles and passesIssues/PRs references
None