scsi: bnx2i: Make bnx2i_process_iscsi_error() simpler and more robust
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 10 Mar 2021 22:16:02 +0000 (23:16 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 25 Mar 2021 02:21:31 +0000 (22:21 -0400)
commitadb253433dc8bc8dd569ee03b233fed21afc1dc7
tree760d97300c56e13d75634b347d8a688e2d80b18f
parentbe20b96b63197eb2e87ffa8973fadb194a16ee80
scsi: bnx2i: Make bnx2i_process_iscsi_error() simpler and more robust

Instead of strcpy'ing into a stack buffer, just let additional_notice point
to a string literal living in .rodata. This is better in a few ways:

 - Smaller .text - instead of gcc compiling the strcpys as a bunch of
   immediate stores (effectively encoding the string literal in the
   instruction stream), we only pay the price of storing the literal in
   .rodata.

 - Faster, because there's no string copying.

 - Smaller stack usage (with my compiler, 72 bytes instead of 176 for the
   sole caller, bnx2i_indicate_kcqe)

Moreover, it's currently possible for additional_notice[] to get used
uninitialized, so some random stack garbage would be passed to printk() -
in the worst case without any '\0' anywhere in those 64 bytes. That could
be fixed by initializing additional_notice[0], but the same is achieved
here by initializing the new pointer variable to "".

Also give the message pointer a similar treatment - there's no point making
temporary copies on the stack of those two strings.

Link: https://lore.kernel.org/r/20210310221602.2494422-1-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/bnx2i/bnx2i_hwi.c