crypto: qat - avoid an uninitialized variable warning
authorArnd Bergmann <arnd@arndb.de>
Thu, 22 Jun 2017 12:35:46 +0000 (14:35 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 28 Jun 2017 13:54:58 +0000 (06:54 -0700)
commit72eed063767e131831fa10a0909c39a0254836ec
treeefbdc4af62c07473102982fe0931fed1c43939cd
parentc4d9d598fd2a82136175706e599c4150d0962b1b
crypto: qat - avoid an uninitialized variable warning

After commit 9e442aa6a753 ("x86: remove DMA_ERROR_CODE"), the inlining
decisions in the qat driver changed slightly, introducing a new false-positive
warning:

drivers/crypto/qat/qat_common/qat_algs.c: In function 'qat_alg_sgl_to_bufl.isra.6':
include/linux/dma-mapping.h:228:2: error: 'sz_out' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/crypto/qat/qat_common/qat_algs.c:676:9: note: 'sz_out' was declared here

The patch that introduced this is correct, so let's just avoid the
warning in this driver by rearranging the unwinding after an error
to make it more obvious to the compiler what is going on.

The problem here is the 'if (unlikely(dma_mapping_error(dev, blp)))'
check, in which the 'unlikely' causes gcc to forget what it knew about
the state of the variables. Cleaning up the dma state in the reverse
order it was created means we can simplify the logic so it doesn't have
to know about that state, and also makes it easier to understand.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/crypto/qat/qat_common/qat_algs.c