Skip to content

acl_hash: fix signedness conversion warnings for internal tail buffer #84

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

Merged
merged 1 commit into from
Feb 22, 2022
Merged

acl_hash: fix signedness conversion warnings for internal tail buffer #84

merged 1 commit into from
Feb 22, 2022

Conversation

pcolberg
Copy link
Contributor

@pcolberg pcolberg commented Feb 18, 2022

The signedness of char is platform-dependent, e.g., signed on the
platforms supported by the runtime, which causes the following integer
conversion warnings. char is appropriate for a buffer of characters,
whereas unsigned char is appropriate for a buffer of arbitrary bytes.

The signedness change only affects the internal implementation, i.e. the
internal tail buffer and the internal functions using that buffer. The
unit tests provide sufficient coverage to ensure correctness.

[2/14] Building C object lib/acl_hash/CMakeFiles/acl_hash.dir/src/acl_hash.c.o
../lib/acl_hash/src/acl_hash.c: In function ‘l_close’:
../lib/acl_hash/src/acl_hash.c:189:14: warning: conversion to ‘char’ alters ‘int’ constant value [-Wconversion]
   extra[0] = 0x80; // append '1' bit. Assume big endian even within byte.
              ^~~~
../lib/acl_hash/src/acl_hash.c:199:20: warning: conversion to ‘char’ from ‘uint64_t {aka long unsigned int}’ may alter its value [-Wconversion]
     extra[7 - i] = user_bits & 0xff;
                    ^~~~~~~~~

Prerequisite of #85

The signedness of `char` is platform-dependent, e.g., signed on the
platforms supported by the runtime, which causes the following integer
conversion warnings. `char` is appropriate for a buffer of characters,
whereas `unsigned char` is appropriate for a buffer of arbitrary bytes.

The signedness change only affects the internal implementation, i.e. the
internal tail buffer and the internal functions using that buffer. The
unit tests provide sufficient coverage to ensure correctness.

[2/14] Building C object lib/acl_hash/CMakeFiles/acl_hash.dir/src/acl_hash.c.o
../lib/acl_hash/src/acl_hash.c: In function ‘l_close’:
../lib/acl_hash/src/acl_hash.c:189:14: warning: conversion to ‘char’ alters ‘int’ constant value [-Wconversion]
   extra[0] = 0x80; // append '1' bit. Assume big endian even within byte.
              ^~~~
../lib/acl_hash/src/acl_hash.c:199:20: warning: conversion to ‘char’ from ‘uint64_t {aka long unsigned int}’ may alter its value [-Wconversion]
     extra[7 - i] = user_bits & 0xff;
                    ^~~~~~~~~
@pcolberg pcolberg added this to the 2022.3 milestone Feb 18, 2022
@pcolberg pcolberg self-assigned this Feb 18, 2022
@pcolberg pcolberg requested a review from zibaiwan February 18, 2022 23:26
Copy link
Contributor

@zibaiwan zibaiwan left a comment

Choose a reason for hiding this comment

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

Thanks Peter for fixing this warning!

@pcolberg pcolberg merged commit 0e228b5 into intel:main Feb 22, 2022
@pcolberg pcolberg deleted the acl-hash-unsigned-char branch February 22, 2022 16:50
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