]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
common/armor: mark dst_end a const pointer
authorKefu Chai <kchai@redhat.com>
Thu, 24 Jun 2021 05:05:22 +0000 (13:05 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 24 Jun 2021 05:05:23 +0000 (13:05 +0800)
commitab709e0c22f15fb0b2ee7f71a8e0b32d4316fe8f
tree539530b803507032e2f9fa5132db5986f3f51056
parent9145d9c8091ed620a2f2b9527da13bf04ca568a7
common/armor: mark dst_end a const pointer

to silence GCC-11 warnings like:

../src/common/secret.c: In function ‘set_kernel_secret’:
../src/common/secret.c:65:9: warning: ‘<unknown>’ may be used uninitialized [-Wmaybe-uninitialized]
   65 |   ret = ceph_unarmor(payload, payload+sizeof(payload), secret, secret+secret_len);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/common/secret.c:23:
../src/common/armor.h:14:5: note: by argument 2 of type ‘const char *’ to ‘ceph_unarmor’ declared here
   14 | int ceph_unarmor(char *dst, const char *dst_end,
      |     ^~~~~~~~~~~~

see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100417

this warning is false positive. but it's still annoying.

since semantically, we are changing the dst buffer, and the dst_end
specify the non-inclusive upper bound of the output buffer, this
change is not quite wrong by changing the type of this pointer
from a pointer to a const char to a constant pointer to a (mutable) char.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/armor.c
src/common/armor.h