Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yadro.com header.i=@yadro.com header.b="XF10T0WQ"; dkim=pass (2048-bit key) header.d=yadro.com header.i=@yadro.com header.b="TJ3WGAhV" Received: from mta-04.yadro.com (mta-04.yadro.com [89.207.88.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B910093 for ; Wed, 13 Dec 2023 02:52:59 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 0BB30C0004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yadro.com; s=mta-04; t=1702464778; bh=0ANX21fvWXKVlojafEh9VSyHH1AYJA3xOreFehil6Q4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:From; b=XF10T0WQVXiltqsQAYwP2a1Wbc8kFxlXr6xynDwEglzbkO6gP43JkCDOFdoEak5ck qZ45z9mKQUBthcq62YNOrXMhOUNcq4qCLYHdtCjyvSKG2WjFbMRotn2upD+ZUXUvjY WT5YAJiv8M+bh0iOsSlA6Gp9KoECNfemLnJTvTsGymcbbgbnnl2lD3cTo7WXnWNQjS Mi5PZM5IpMzWOxEhqHvXDygRSQGyEAnL2AFu2+HV1q0261gJ/Rq4QBhyY+8/y+UEih Mt7ED6qXg2OjiRQnw6kbM2I2nWSs6MLOlrXP4yLYkwWlS1LIhmvuw+SFRBN0qJog0V 5PPXtHnBIIOGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yadro.com; s=mta-03; t=1702464778; bh=0ANX21fvWXKVlojafEh9VSyHH1AYJA3xOreFehil6Q4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:From; b=TJ3WGAhVaz3Y9/CGCgOiioTgAZvNw5gT3ZWqgjypjOkh0EgKcBhXlfoKfPQ12bLbW n21IYkwaJK730s9J+czpDcw/DUIM2Q5KGh5I1Y6HybEyOcc6mtpdT00PCY1L5OZjtz Bx8bj0UYX4M4Y7z8DrQOgZcBj4qZm6dJ0ZFq+kKwU8BOnWAtVlbwz3eBS6KipLW28M fiYtZoELV3hY+KZ6ug+pl0R4cEfrdhu/AaaAhZG2+NObpfnZTIrT+kvc7Zu1CSbvUR GuwLtNua4nIeNTxTuPaT88qZ7F4oDu0+8MX7N5qJhRd5KEjwEJZnhrB840XaMm9tor 7OAfLf8IE+Jpg== Date: Wed, 13 Dec 2023 13:52:56 +0300 From: Nikita Proshkin To: Martin =?UTF-8?B?TWFyZcWh?= CC: , , Sergei Miroshnichenko , Nikita Proshkin Subject: Re: [PATCH 13/15] pciutils-pcilmr: Add option to save margining results in csv form Message-ID: <20231213135256.145556b6.n.proshkin@yadro.com> In-Reply-To: References: <20231208091734.12225-1-n.proshkin@yadro.com> <20231208091734.12225-14-n.proshkin@yadro.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: T-EXCH-06.corp.yadro.com (172.17.10.110) To T-EXCH-08.corp.yadro.com (172.17.11.58) On Fri, 8 Dec 2023 18:44:23 +0100 Martin Mare=C5=A1 wrote: > > + if (!csv) > > + { > > + printf("Error while saving %s\n", path); > > + free(path); > > + return; > > + } >=20 > We have die(...) for that. I think that die() from common.c is not suitable here, as the utility at th= at moment in the code still can and must free up resources malloc'ed in the ma= in function.=20 > > + char timestamp[64]; > > + time_t tim =3D time(NULL); > > + strftime(timestamp, 64, "%FT%H.%M.%S", gmtime(&tim)); >=20 > Please use sizeof(timestamp) to make the code more robust. >=20 > > + char *path =3D (char *)malloc((strlen(dir) + 128) * sizeof(*path)); >=20 > Please use xmalloc(). >=20 > > + sprintf(path, "%s/lmr_%0*x.%02x.%02x.%x_Rx%X_%s.csv", dir, >=20 > Please avoid plain sprintf() everywhere and use snprintf() instead. >=20 > > + for (uint8_t j =3D 0; j < recv->lanes_n; j++) >=20 > It's better to use plain integer types ("int" or "unsigned int") for > loop control variables. Everything else will be fixed.=20 Best regards, Nikita Proshkin