From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: nfp doing its own pci_read_config Date: Mon, 30 Apr 2018 08:19:42 -0700 Message-ID: <20180430081942.1aa34385@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: alejandro.lucero@netronome.com, dev@dpdk.org Return-path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 4D351DD2 for ; Mon, 30 Apr 2018 17:19:45 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id f189so6978915pfa.7 for ; Mon, 30 Apr 2018 08:19:45 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "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;