
Hi Fabio,
-----Original Message----- From: Fabio Estevam [mailto:festevam@gmail.com] Sent: 2018年11月1日 18:18 To: Peng Fan peng.fan@nxp.com Cc: Stefano Babic sbabic@denx.de; Fabio Estevam fabio.estevam@nxp.com; U-Boot-Denx u-boot@lists.denx.de; dl-linux-imx linux-imx@nxp.com Subject: Re: [U-Boot] [PATCH 1/4] tools: imx8image: check lseek return value Hi Peng,
On Thu, Nov 1, 2018 at 3:42 AM Peng Fan peng.fan@nxp.com wrote:
size = sbuf.st_size;
lseek(ifd, offset, SEEK_SET);
if (lseek(ifd, offset, SEEK_SET) == -1) {
fprintf(stderr, "%s: lseek error %s\n",
__func__, strerror(errno));
exit(EXIT_FAILURE);
}
What about something like this instead?
ret = lseek(ifd, offset, SEEK_SET); if (ret < 0) { fprintf(stderr, "%s: lseek error: %d\n", __func__, ret); exit(EXIT_FAILURE); }
lseek only returns -1 when error. Is the coding style you proposed is preferred than what this patch has? I saw fit_image use if (xxx < 0) and fw_env.c use if (xxx == -1), there are also others use ret = lseek().
Thanks, Peng.