Skip to content
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

Generated code causes warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] #421

Open
StefanHri opened this issue Apr 21, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@StefanHri
Copy link

Using the latest version zcbor in the uoscore-uedhoc causes the following warnings:

src/cbor/edhoc_encode_bstr_type.c: In function ‘cbor_encode_bstr_type_b_str’:
src/cbor/edhoc_encode_bstr_type.c:48:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   48 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_data_2.c
src/cbor/edhoc_encode_data_2.c: In function ‘cbor_encode_data_2’:
src/cbor/edhoc_encode_data_2.c:72:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   72 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_enc_structure.c
src/cbor/edhoc_encode_enc_structure.c: In function ‘cbor_encode_edhoc_enc_structure’:
src/cbor/edhoc_encode_enc_structure.c:50:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   50 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_id_cred_x.c
src/cbor/edhoc_encode_id_cred_x.c: In function ‘cbor_encode_id_cred_x_map’:
src/cbor/edhoc_encode_id_cred_x.c:235:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  235 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_info.c
src/cbor/edhoc_encode_info.c: In function ‘cbor_encode_info’:
src/cbor/edhoc_encode_info.c:50:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   50 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_int_type.c
src/cbor/edhoc_encode_int_type.c: In function ‘cbor_encode_int_type_i’:
src/cbor/edhoc_encode_int_type.c:48:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   48 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_message_1.c
src/cbor/edhoc_encode_message_1.c: In function ‘cbor_encode_message_1’:
src/cbor/edhoc_encode_message_1.c:56:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   56 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_message_2.c
src/cbor/edhoc_encode_message_2.c: In function ‘cbor_encode_m2’:
src/cbor/edhoc_encode_message_2.c:51:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   51 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_message_3.c
src/cbor/edhoc_encode_message_3.c: In function ‘cbor_encode_m3_CIPHERTEXT_3’:
src/cbor/edhoc_encode_message_3.c:48:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   48 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_message_error.c
src/cbor/edhoc_encode_message_error.c: In function ‘cbor_encode_message_error’:
src/cbor/edhoc_encode_message_error.c:90:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   90 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_sig_structure.c
src/cbor/edhoc_encode_sig_structure.c: In function ‘cbor_encode_sig_structure’:
src/cbor/edhoc_encode_sig_structure.c:51:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   51 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/edhoc_encode_th2.c
src/cbor/edhoc_encode_th2.c: In function ‘cbor_encode_th2’:
src/cbor/edhoc_encode_th2.c:52:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   52 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/oscore_aad_array.c
src/cbor/oscore_aad_array.c: In function ‘cbor_encode_aad_array’:
src/cbor/oscore_aad_array.c:54:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   54 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/oscore_enc_structure.c
src/cbor/oscore_enc_structure.c: In function ‘cbor_encode_oscore_enc_structure’:
src/cbor/oscore_enc_structure.c:50:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   50 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
      |                                                           ^
[Compile] src/cbor/oscore_info.c
src/cbor/oscore_info.c: In function ‘cbor_encode_oscore_info’:
src/cbor/oscore_info.c:56:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
   56 |         return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,

Generally the uoscore-uedhoc project is using the following warning flags:

EXTENDED_CFLAGS += -Wcast-qual
EXTENDED_CFLAGS += -Wconversion
EXTENDED_CFLAGS += -Wexit-time-destructors
EXTENDED_CFLAGS += -Wglobal-constructors
EXTENDED_CFLAGS += -Wmissing-noreturn
EXTENDED_CFLAGS += -Wmissing-prototypes
EXTENDED_CFLAGS += -Wno-missing-braces
EXTENDED_CFLAGS += -Wold-style-cast
EXTENDED_CFLAGS += -Wshadow
EXTENDED_CFLAGS += -Wweak-vtables
EXTENDED_CFLAGS += -Wall
EXTENDED_CFLAGS += -Wextra
EXTENDED_CFLAGS += -Wpedantic
EXTENDED_CFLAGS += -Wstack-exhausted
EXTENDED_CFLAGS += -Wconversion

Would it be possible to make sure that the code generated by zcbor is not triggering those? Thanks!

@oyvindronningstad
Copy link
Collaborator

Which C standard are you using? My experience is that the different -W flags behave differently between them.

@StefanHri
Copy link
Author

c11

@oyvindronningstad oyvindronningstad added the enhancement New feature or request label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants