From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40111A0524; Tue, 1 Jun 2021 07:37:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B51E240041; Tue, 1 Jun 2021 07:37:53 +0200 (CEST) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id 09E6E40040 for ; Tue, 1 Jun 2021 07:37:52 +0200 (CEST) Received: by mail-pg1-f172.google.com with SMTP id n12so6618866pgs.13 for ; Mon, 31 May 2021 22:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1iuVTlphDNohq2U5mEfT+WqdgqvaEshNMoKfihTsRQc=; b=BcgFVD1NFApClGAlDOpbl5rDkv0cuvmVIVKvJniRqeaOGaRrqbRcvuEsnTlwB/HD/M uknKTGkEM6olUPArvRx+8lt7EGzxIbDzpRr33K51nZNb/D14ZZhxEpkZvbG+bTxFPimD wa3vgS3wUqboJZftWbxklgwLveSz6dP+iKOSmOOSNZ3lb5SR5nsClmmNsmaG/f/t04QV +Zo8EVKirzHt2rCZxS7ZFM1u9nPTx8rmMEywtq0wxT18pjSzDu9YvSo4f2VLtoYOY50k GcGcx8SBH2HJOR9YJLd2Gn+SX1Xwp6Uq/yFEGcQCVj1BZoPdrv+DQwuFlG3wTnp+gspW igUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1iuVTlphDNohq2U5mEfT+WqdgqvaEshNMoKfihTsRQc=; b=D3VVCI+JqcFWTURd9qE7OIPGjGRlFW3wgFaEWU7K+rgUrG9sT6q8cMWYoSJgZTXpp9 635RKs1Eub93J/0pYgUo7p02PXW+578X6o8fVIDB7e7AKnaGXJvivzuqefNce2FvfJBY Ke0eZGs7sBHXc2ymim8f8Zsfti9Qdf+ofuYJr0CiSnRts0cFYn6FiWE9gK6AfU+SVRar rFaM/pCI6iHkyRp+cUbxw4BUEJJGoHJBer/ecKzj12RDo0u9y6cj+MrDABk7NnBQL82K LEQpDgAEps8W5EsXDY2MCI4nuBeEY0wQhJ1yTD4dF8aO+xXDtuvme2eZ2zSgRT/5W7cG T6Jw== X-Gm-Message-State: AOAM533sR21ZZ0FgBrCT1oWWSW6G0+CGd3C1bGWEcWvtcZRvgnQDNJFL AqL+/C+buHxOy8x3KUUo+6lecg== X-Google-Smtp-Source: ABdhPJwxnhopCnjjYqLsMsWUYk3+6KV2PRaLoegXaE37A67HsaNzJW8/OX2aIS79jXUMW1+JN8FCrw== X-Received: by 2002:a63:604:: with SMTP id 4mr10900625pgg.58.1622525871885; Mon, 31 May 2021 22:37:51 -0700 (PDT) Received: from hermes.local (76-14-218-44.or.wavecable.com. [76.14.218.44]) by smtp.gmail.com with ESMTPSA id q9sm1037009pjm.23.2021.05.31.22.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 22:37:51 -0700 (PDT) Date: Mon, 31 May 2021 22:37:43 -0700 From: Stephen Hemminger To: Chenbo Xia Cc: dev@dpdk.org, thomas@monjalon.net, cunming.liang@intel.com, jingjing.wu@intel.com, anatoly.burakov@intel.com, ferruh.yigit@intel.com, mdr@ashroe.eu, nhorman@tuxdriver.com, bruce.richardson@intel.com, david.marchand@redhat.com, konstantin.ananyev@intel.com, Tiwei Bie Message-ID: <20210531223743.41a21fdd@hermes.local> In-Reply-To: <20210601030644.3318-5-chenbo.xia@intel.com> References: <20190715075214.16616-6-tiwei.bie@intel.com> <20210601030644.3318-1-chenbo.xia@intel.com> <20210601030644.3318-5-chenbo.xia@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC v3 4/6] eal: add a helper for reading string from sysfs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 1 Jun 2021 11:06:42 +0800 Chenbo Xia wrote: > +int > +rte_eal_parse_sysfs_str(const char *filename, char *buf, unsigned long sz) > +{ > + FILE *f; > + > + f = fopen(filename, "r"); > + if (f == NULL) { > + RTE_LOG(ERR, EAL, "%s(): cannot open sysfs file %s\n", > + __func__, filename); > + return -1; > + } > + > + if (fgets(buf, sz, f) == NULL) { > + RTE_LOG(ERR, EAL, "%s(): cannot read sysfs file %s\n", > + __func__, filename); > + fclose(f); > + return -1; > + } > + > + fclose(f); > + return 0; > +} It would be helpful if function removed trailing newline. strchrnul(buf, '\n') = '\0';