drivers/net/ethernet/google/gve/gve_tx.c:507:25: warning: variable 'buf' set but not used

From: kernel test robot
Date: Fri Jan 01 2021 - 12:00:52 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f6e1ea19649216156576aeafa784e3b4cee45549
commit: 6f007c6486d69967ac1d9e67df9ae9c77d49f1cc gve: Add support for raw addressing in the tx path
date: 3 weeks ago
config: i386-randconfig-r034-20210101 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f007c6486d69967ac1d9e67df9ae9c77d49f1cc
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6f007c6486d69967ac1d9e67df9ae9c77d49f1cc
# save the attached .config to linux build tree
make W=1 ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/net/ethernet/google/gve/gve_tx.c: In function 'gve_tx_add_skb_no_copy':
>> drivers/net/ethernet/google/gve/gve_tx.c:507:25: warning: variable 'buf' set but not used [-Wunused-but-set-variable]
507 | struct gve_tx_dma_buf *buf;
| ^~~


vim +/buf +507 drivers/net/ethernet/google/gve/gve_tx.c

497
498 static int gve_tx_add_skb_no_copy(struct gve_priv *priv, struct gve_tx_ring *tx,
499 struct sk_buff *skb)
500 {
501 const struct skb_shared_info *shinfo = skb_shinfo(skb);
502 int hlen, payload_nfrags, l4_hdr_offset;
503 union gve_tx_desc *pkt_desc, *seg_desc;
504 struct gve_tx_buffer_state *info;
505 bool is_gso = skb_is_gso(skb);
506 u32 idx = tx->req & tx->mask;
> 507 struct gve_tx_dma_buf *buf;
508 u64 addr;
509 u32 len;
510 int i;
511
512 info = &tx->info[idx];
513 pkt_desc = &tx->desc[idx];
514
515 l4_hdr_offset = skb_checksum_start_offset(skb);
516 /* If the skb is gso, then we want only up to the tcp header in the first segment
517 * to efficiently replicate on each segment otherwise we want the linear portion
518 * of the skb (which will contain the checksum because skb->csum_start and
519 * skb->csum_offset are given relative to skb->head) in the first segment.
520 */
521 hlen = is_gso ? l4_hdr_offset + tcp_hdrlen(skb) : skb_headlen(skb);
522 len = skb_headlen(skb);
523
524 info->skb = skb;
525
526 addr = dma_map_single(tx->dev, skb->data, len, DMA_TO_DEVICE);
527 if (unlikely(dma_mapping_error(tx->dev, addr))) {
528 tx->dma_mapping_error++;
529 goto drop;
530 }
531 buf = &info->buf;
532 dma_unmap_len_set(buf, len, len);
533 dma_unmap_addr_set(buf, dma, addr);
534
535 payload_nfrags = shinfo->nr_frags;
536 if (hlen < len) {
537 /* For gso the rest of the linear portion of the skb needs to
538 * be in its own descriptor.
539 */
540 payload_nfrags++;
541 gve_tx_fill_pkt_desc(pkt_desc, skb, is_gso, l4_hdr_offset,
542 1 + payload_nfrags, hlen, addr);
543
544 len -= hlen;
545 addr += hlen;
546 idx = (tx->req + 1) & tx->mask;
547 seg_desc = &tx->desc[idx];
548 gve_tx_fill_seg_desc(seg_desc, skb, is_gso, len, addr);
549 } else {
550 gve_tx_fill_pkt_desc(pkt_desc, skb, is_gso, l4_hdr_offset,
551 1 + payload_nfrags, hlen, addr);
552 }
553
554 for (i = 0; i < shinfo->nr_frags; i++) {
555 const skb_frag_t *frag = &shinfo->frags[i];
556
557 idx = (idx + 1) & tx->mask;
558 seg_desc = &tx->desc[idx];
559 len = skb_frag_size(frag);
560 addr = skb_frag_dma_map(tx->dev, frag, 0, len, DMA_TO_DEVICE);
561 if (unlikely(dma_mapping_error(tx->dev, addr))) {
562 tx->dma_mapping_error++;
563 goto unmap_drop;
564 }
565 buf = &tx->info[idx].buf;
566 tx->info[idx].skb = NULL;
567 dma_unmap_len_set(buf, len, len);
568 dma_unmap_addr_set(buf, dma, addr);
569
570 gve_tx_fill_seg_desc(seg_desc, skb, is_gso, len, addr);
571 }
572
573 return 1 + payload_nfrags;
574
575 unmap_drop:
576 i += (payload_nfrags == shinfo->nr_frags ? 1 : 2);
577 while (i--) {
578 idx--;
579 gve_tx_unmap_buf(tx->dev, &tx->info[idx & tx->mask]);
580 }
581 drop:
582 tx->dropped_pkt++;
583 return 0;
584 }
585

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip