Skip to content

Commit 071a43e

Browse files
arndbdavem330
authored andcommitted
cxgb4/chcr: avoid -Wreturn-local-addr warning
gcc-10 warns about functions that return a pointer to a stack variable. In chcr_write_cpl_set_tcb_ulp(), this does not actually happen, but it's too hard to see for the compiler: drivers/crypto/chelsio/chcr_ktls.c: In function 'chcr_write_cpl_set_tcb_ulp.constprop': drivers/crypto/chelsio/chcr_ktls.c:760:9: error: function may return address of local variable [-Werror=return-local-addr] 760 | return pos; | ^~~ drivers/crypto/chelsio/chcr_ktls.c:712:5: note: declared here 712 | u8 buf[48] = {0}; | ^~~ Split the middle part of the function out into a helper to make it easier to understand by both humans and compilers, which avoids the warning. Fixes: 5a4b9fe ("cxgb4/chcr: complete record tx handling") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c649c41 commit 071a43e

1 file changed

Lines changed: 46 additions & 37 deletions

File tree

‎drivers/crypto/chelsio/chcr_ktls.c‎

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -673,41 +673,14 @@ int chcr_ktls_cpl_set_tcb_rpl(struct adapter *adap, unsigned char *input)
673673
return 0;
674674
}
675675

676-
/*
677-
* chcr_write_cpl_set_tcb_ulp: update tcb values.
678-
* TCB is responsible to create tcp headers, so all the related values
679-
* should be correctly updated.
680-
* @tx_info - driver specific tls info.
681-
* @q - tx queue on which packet is going out.
682-
* @tid - TCB identifier.
683-
* @pos - current index where should we start writing.
684-
* @word - TCB word.
685-
* @mask - TCB word related mask.
686-
* @val - TCB word related value.
687-
* @reply - set 1 if looking for TP response.
688-
* return - next position to write.
689-
*/
690-
static void *chcr_write_cpl_set_tcb_ulp(struct chcr_ktls_info *tx_info,
691-
struct sge_eth_txq *q, u32 tid,
692-
void *pos, u16 word, u64 mask,
676+
static void *__chcr_write_cpl_set_tcb_ulp(struct chcr_ktls_info *tx_info,
677+
u32 tid, void *pos, u16 word, u64 mask,
693678
u64 val, u32 reply)
694679
{
695680
struct cpl_set_tcb_field_core *cpl;
696681
struct ulptx_idata *idata;
697682
struct ulp_txpkt *txpkt;
698-
void *save_pos = NULL;
699-
u8 buf[48] = {0};
700-
int left;
701683

702-
left = (void *)q->q.stat - pos;
703-
if (unlikely(left < CHCR_SET_TCB_FIELD_LEN)) {
704-
if (!left) {
705-
pos = q->q.desc;
706-
} else {
707-
save_pos = pos;
708-
pos = buf;
709-
}
710-
}
711684
/* ULP_TXPKT */
712685
txpkt = pos;
713686
txpkt->cmd_dest = htonl(ULPTX_CMD_V(ULP_TX_PKT) | ULP_TXPKT_DEST_V(0));
@@ -732,18 +705,54 @@ static void *chcr_write_cpl_set_tcb_ulp(struct chcr_ktls_info *tx_info,
732705
idata = (struct ulptx_idata *)(cpl + 1);
733706
idata->cmd_more = htonl(ULPTX_CMD_V(ULP_TX_SC_NOOP));
734707
idata->len = htonl(0);
708+
pos = idata + 1;
735709

736-
if (save_pos) {
737-
pos = chcr_copy_to_txd(buf, &q->q, save_pos,
738-
CHCR_SET_TCB_FIELD_LEN);
739-
} else {
740-
/* check again if we are at the end of the queue */
741-
if (left == CHCR_SET_TCB_FIELD_LEN)
710+
return pos;
711+
}
712+
713+
714+
/*
715+
* chcr_write_cpl_set_tcb_ulp: update tcb values.
716+
* TCB is responsible to create tcp headers, so all the related values
717+
* should be correctly updated.
718+
* @tx_info - driver specific tls info.
719+
* @q - tx queue on which packet is going out.
720+
* @tid - TCB identifier.
721+
* @pos - current index where should we start writing.
722+
* @word - TCB word.
723+
* @mask - TCB word related mask.
724+
* @val - TCB word related value.
725+
* @reply - set 1 if looking for TP response.
726+
* return - next position to write.
727+
*/
728+
static void *chcr_write_cpl_set_tcb_ulp(struct chcr_ktls_info *tx_info,
729+
struct sge_eth_txq *q, u32 tid,
730+
void *pos, u16 word, u64 mask,
731+
u64 val, u32 reply)
732+
{
733+
int left = (void *)q->q.stat - pos;
734+
735+
if (unlikely(left < CHCR_SET_TCB_FIELD_LEN)) {
736+
if (!left) {
742737
pos = q->q.desc;
743-
else
744-
pos = idata + 1;
738+
} else {
739+
u8 buf[48] = {0};
740+
741+
__chcr_write_cpl_set_tcb_ulp(tx_info, tid, buf, word,
742+
mask, val, reply);
743+
744+
return chcr_copy_to_txd(buf, &q->q, pos,
745+
CHCR_SET_TCB_FIELD_LEN);
746+
}
745747
}
746748

749+
pos = __chcr_write_cpl_set_tcb_ulp(tx_info, tid, pos, word,
750+
mask, val, reply);
751+
752+
/* check again if we are at the end of the queue */
753+
if (left == CHCR_SET_TCB_FIELD_LEN)
754+
pos = q->q.desc;
755+
747756
return pos;
748757
}
749758

0 commit comments

Comments
 (0)