DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] nfp doing its own pci_read_config
@ 2018-04-30 15:19 Stephen Hemminger
  0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2018-04-30 15:19 UTC (permalink / raw)
  To: alejandro.lucero, dev

Why is Netronome driver using its own version of existing rte_pci_read_config?
And hard coding magic numbers for offsets.

This shows up as Coverity error
________________________________________________________________________________________________________
*** CID 277243:  Error handling issues  (CHECKED_RETURN)
/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c: 684 in nfp6000_set_interface()
678     		 desc->busdev);
679     
680     	fp = open(tmp_str, O_RDONLY);
681     	if (!fp)
682     		return -1;
683     
>>>     CID 277243:  Error handling issues  (CHECKED_RETURN)
>>>     Calling "lseek(fp, 340L, 0)" without checking return value. This library function may fail and return an error code.  
684     	lseek(fp, 0x154, SEEK_SET);
685     
686     	if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
687     		printf("error reading config file for interface\n");
688     		return -1;
689  


static int
nfp6000_set_model(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)
{
	char tmp_str[80];
	uint32_t tmp;
	int fp;

	snprintf(tmp_str, sizeof(tmp_str), "%s/%s/config", PCI_DEVICES,
		 desc->busdev);

	fp = open(tmp_str, O_RDONLY);
	if (!fp)
		return -1;

	lseek(fp, 0x2e, SEEK_SET);

	if (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {
		printf("Error reading config file for model\n");
		return -1;
	}

	tmp = tmp << 16;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-30 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 15:19 [dpdk-dev] nfp doing its own pci_read_config Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).