Am Sonntag 30 September 2012, 13:07:54 schrieb Paul Bolle: > Compiling qla_gs.o (part of the qla2xxx module) triggers two GCC > warnings: > drivers/scsi/qla2xxx/qla_gs.c: In function ‘qla2x00_fdmi_rhba’: > drivers/scsi/qla2xxx/qla_gs.c:1339:7: warning: array subscript is above > array bounds [-Warray-bounds] drivers/scsi/qla2xxx/qla_gs.c: In function > ‘qla2x00_fdmi_register’: drivers/scsi/qla2xxx/qla_gs.c:1663:15: warning: > array subscript is above array bounds [-Warray-bounds] > > It seems that the sequence of a strcpy followed by a strlen confuses GCC > when it is keeping track of array bounds here. (It is not clear to me > which array triggers this warning and by how much GCC thinks the > subscript is above its bounds. Neither is it clear to me why comparable > code in these two functions doesn't trigger this warning.) > > The easiest way to silence these warnings is to hardcode the length of > these two strings in the code here. The length used here is the length > of the string, including its NUL terminator, rounded up to the next > multiple of four. This adds some magic values, which is asking for trouble once someone changes the manufacturer string or something. What about something like this: const char *qlogic = "QLogic Corporation"; strcpy(eiter->a.manufacturer, qlogic); alen += round_up(strlen(qlogic), 4); ... Eike
Attachment:
signature.asc
Description: This is a digitally signed message part.