open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

Fix gcc-10 warning about zero-length arrays. #58

Closed gonzoleeman closed 4 years ago

gonzoleeman commented 4 years ago

There are two zero-length arrays used, in struct isns_hdr and struct isns_tlv, that are really meant as place-holders for allocated arrays. These need to be declared as empty arrays instead of zero- length arrays, since this is the accepted way of handling such data these days.

This fixes a gcc-10 warning that looks like:

In function ‘isns_rsp_handle’, inlined from ‘isns_handle’ at .../src/isns.c:789:3: .../src/isns.c:724:34: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 724 | ((char ) tlv->value + slen) = '\0'; | ^ .../src/isns.c: In function ‘isns_handle’: .../src/isns_proto.h:33:11: note: at offset 0 to object ‘value’ with size 0 declared here 33 | uint32_t value[0]; | ^

gonzoleeman commented 4 years ago

I believe I got this right this time. No merge tirds, and the proper fix for zero-length array usage.

cvubrugier commented 4 years ago

Thanks @gonzoleeman!