Skip to content

Commit b741ecc

Browse files
committed
dpdk: suppress -Wformat-truncation warnings.
This doesn't fix them - nothing short of changing the way we generate error message strings will do that - but at least it means we don't get annoyed by them, and it also marks places that would need to be changed if we change the way we generate those error message strings. See #1544 for an issue for making those changes. This addresses part of #1543.
1 parent 21ed998 commit b741ecc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pcap-dpdk.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ env DPDK_CFG="--log-level=debug -l0 -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so
112112
#include <rte_bus.h>
113113
#include <rte_version.h>
114114

115+
#include "diag-control.h"
116+
115117
#include "pcap-int.h"
116118
#include "pcap-dpdk.h"
117119

@@ -781,18 +783,22 @@ static int pcap_dpdk_activate(pcap_t *p)
781783
if (ret < 0)
782784
{
783785
// This returns a negative value on an error.
786+
DIAG_OFF_FORMAT_TRUNCATION
784787
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
785788
"Can't open device %s: %s",
786789
p->opt.device, dpdk_pre_init_errbuf);
790+
DIAG_ON_FORMAT_TRUNCATION
787791
// ret is set to the correct error
788792
break;
789793
}
790794
if (ret == 0)
791795
{
792796
// This means DPDK isn't available on this machine.
797+
DIAG_OFF_FORMAT_TRUNCATION
793798
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
794799
"Can't open device %s: DPDK is not available on this machine",
795800
p->opt.device);
801+
DIAG_ON_FORMAT_TRUNCATION
796802
return PCAP_ERROR_NO_SUCH_DEVICE;
797803
}
798804

@@ -809,17 +815,21 @@ static int pcap_dpdk_activate(pcap_t *p)
809815
nb_ports = rte_eth_dev_count_avail();
810816
if (nb_ports == 0)
811817
{
818+
DIAG_OFF_FORMAT_TRUNCATION
812819
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
813820
"dpdk error: No Ethernet ports");
821+
DIAG_ON_FORMAT_TRUNCATION
814822
ret = PCAP_ERROR;
815823
break;
816824
}
817825

818826
portid = portid_by_device(p->opt.device);
819827
if (portid == DPDK_PORTID_MAX){
828+
DIAG_OFF_FORMAT_TRUNCATION
820829
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
821830
"dpdk error: portid is invalid. device %s",
822831
p->opt.device);
832+
DIAG_ON_FORMAT_TRUNCATION
823833
ret = PCAP_ERROR_NO_SUCH_DEVICE;
824834
break;
825835
}
@@ -836,9 +846,11 @@ static int pcap_dpdk_activate(pcap_t *p)
836846
rte_socket_id());
837847
if (pd->pktmbuf_pool == NULL)
838848
{
849+
DIAG_OFF_FORMAT_TRUNCATION
839850
dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
840851
PCAP_ERRBUF_SIZE, rte_errno,
841852
"dpdk error: Cannot init mbuf pool");
853+
DIAG_ON_FORMAT_TRUNCATION
842854
ret = PCAP_ERROR;
843855
break;
844856
}
@@ -919,8 +931,10 @@ static int pcap_dpdk_activate(pcap_t *p)
919931
rte_eth_dev_socket_id(portid));
920932
if (tx_buffer == NULL)
921933
{
934+
DIAG_OFF_FORMAT_TRUNCATION
922935
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
923936
"dpdk error: Cannot allocate buffer for tx on port %u", portid);
937+
DIAG_ON_FORMAT_TRUNCATION
924938
ret = PCAP_ERROR;
925939
break;
926940
}
@@ -944,8 +958,10 @@ static int pcap_dpdk_activate(pcap_t *p)
944958
// check link status
945959
is_port_up = check_link_status(portid, &link);
946960
if (!is_port_up){
961+
DIAG_OFF_FORMAT_TRUNCATION
947962
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
948963
"dpdk error: link is down, port=%u",portid);
964+
DIAG_ON_FORMAT_TRUNCATION
949965
ret = PCAP_ERROR_IFACE_NOT_UP;
950966
break;
951967
}
@@ -1033,9 +1049,11 @@ int pcap_dpdk_findalldevs(pcap_if_list_t *devlistp, char *ebuf)
10331049
if (ret < 0)
10341050
{
10351051
// This returns a negative value on an error.
1052+
DIAG_OFF_FORMAT_TRUNCATION
10361053
snprintf(ebuf, PCAP_ERRBUF_SIZE,
10371054
"Can't look for DPDK devices: %s",
10381055
dpdk_pre_init_errbuf);
1056+
DIAG_ON_FORMAT_TRUNCATION
10391057
ret = PCAP_ERROR;
10401058
break;
10411059
}

0 commit comments

Comments
 (0)