From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20A01C433EF for ; Thu, 20 Jan 2022 05:58:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A7D0F82F73; Thu, 20 Jan 2022 06:58:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tVXNnvUe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B54458383B; Thu, 20 Jan 2022 06:58:17 +0100 (CET) Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 907DF80D1C for ; Thu, 20 Jan 2022 06:58:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so4886833pjp.0 for ; Wed, 19 Jan 2022 21:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=MZ9t8rp1sBddzFO+KmoHxERuPU8enFYpnMro0NHQELg=; b=tVXNnvUe2aAOOFNxMxJffNhupohzTop2goZa0J6H5WQYqhOOcDfPHjajUSKO0kbxTy rJGMP3KyORSrf1pJ146dng4KWQWLqD4EAx2A/NrPxYa0aYiS2GEIehJMVv8w3+KGRsKJ j1W0SZwqXyiQRmDjTGrU8a1JuCT3FCAu5KRX3Kbshotb79eFl0AmjIOBSH6g1VgXaGxa lshW8X0OAtKUDdXQHjjap+yMF6yMAZxptfhKm+1uAza/5OuMcxMLzxjVEywMPCiSTvVE ub1WkcosJNJzKS7NySE0774qThFG6vcMNMTPgM006Wtcfu4sPhJucENpZgai+FWpjztd liDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=MZ9t8rp1sBddzFO+KmoHxERuPU8enFYpnMro0NHQELg=; b=h8VFkGk2Trn7qTzuzVcGTKHBr0jyy8NFAVRFYaAdxa1KF3c1K+yksT5r652cVbGds6 s0nzNh466OcKDyzLa5daqgvGlGBjhcdf/hbqShbZeWRKjfoaAh0Js600IHmzafMGfCme 1YlzyPLwNie/7HK5YpEzmnrlfvZkRZo+Csvpwy5G1O/3hmpST+ytwhP7XHiZEZto4oU1 50yjx2lTbu+hUOvkqbdykMsuufScfxT3zKxUoVeRLZcAQ/99NFxz5aJhj/lE9OX3v/ll BoOcr+HHqFY5tQqrhFWr8DOBGMb/Opa+kvNSFY1/IINVg76coGu7VWzhnn2FCyddOjtF 9iiw== X-Gm-Message-State: AOAM5308EwT4vlnjFtGGb5bb9AfvFr8FHdSeeuQzghlyhZ7gWyByCc21 oySnfEBhVY02I++DaIG5r8w/Yw== X-Google-Smtp-Source: ABdhPJwWVfZwEgMAnj7ZgTHMzk2dCF5+JcfWaD0wt7UTIktxhiA1W88Gp9SPzFn9/Vnvgd0TIujJrQ== X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr8808510pjb.198.1642658292893; Wed, 19 Jan 2022 21:58:12 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:35ef:d002:eb6d:1b5]) by smtp.gmail.com with ESMTPSA id s13sm1608487pfu.0.2022.01.19.21.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 21:58:12 -0800 (PST) Date: Thu, 20 Jan 2022 14:58:07 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, masami.hiramatsu@linaro.org, mark.kettenis@xs4all.nl, u-boot@lists.denx.de, agraf@csgraf.de, sjg@chromium.org Subject: Re: [PATCH v9 01/11] tools: mkeficapsule: output messages to stderr instead of stdout Message-ID: <20220120055807.GF42867@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, masami.hiramatsu@linaro.org, mark.kettenis@xs4all.nl, u-boot@lists.denx.de, agraf@csgraf.de, sjg@chromium.org References: <20220118043954.55940-1-takahiro.akashi@linaro.org> <20220118043954.55940-2-takahiro.akashi@linaro.org> <4e77d34b-d4ed-72c1-d9f4-013b7aac3b3f@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e77d34b-d4ed-72c1-d9f4-013b7aac3b3f@gmx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Wed, Jan 19, 2022 at 04:41:15PM +0100, Heinrich Schuchardt wrote: > On 1/18/22 05:39, AKASHI Takahiro wrote: > > All the error messages should be printed out to stderr. > > > > Signed-off-by: AKASHI Takahiro > > --- > > tools/mkeficapsule.c | 35 ++++++++++++++++++----------------- > > 1 file changed, 18 insertions(+), 17 deletions(-) > > > > diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c > > index 4995ba4e0c2a..19d5eea3cb59 100644 > > --- a/tools/mkeficapsule.c > > +++ b/tools/mkeficapsule.c > > @@ -50,7 +50,7 @@ static struct option options[] = { > > > > static void print_usage(void) > > { > > - printf("Usage: %s [options] \n" > > + fprintf(stderr, "Usage: %s [options] \n" > > Using mkimage -h is not an error condition. I will remove this hunk when > merging. A help message will be shown not only by "-h" but also in case that invalid combination of parameters are passed. In this sense, it is part of error messages. Almost of all other tools under tools/ also behave in the same way. -Takahiro Akashi > > "Options:\n" > > > > "\t-f, --fit new FIT image file\n" > > @@ -74,28 +74,29 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, > > u64 offset; > > > > #ifdef DEBUG > > - printf("For output: %s\n", path); > > - printf("\tbin: %s\n\ttype: %pUl\n", bin, guid); > > - printf("\tindex: %ld\n\tinstance: %ld\n", index, instance); > > + fprintf(stderr, "For output: %s\n", path); > > + fprintf(stderr, "\tbin: %s\n\ttype: %pUl\n", bin, guid); > > + fprintf(stderr, "\tindex: %ld\n\tinstance: %ld\n", index, instance); > > This is not an error. I will revert these lines when merging. > > Otherwise > > Reviewed-by: Heinrich Schuchardt > > > #endif > > > > g = fopen(bin, "r"); > > if (!g) { > > - printf("cannot open %s\n", bin); > > + fprintf(stderr, "cannot open %s\n", bin); > > return -1; > > } > > if (stat(bin, &bin_stat) < 0) { > > - printf("cannot determine the size of %s\n", bin); > > + fprintf(stderr, "cannot determine the size of %s\n", bin); > > goto err_1; > > } > > data = malloc(bin_stat.st_size); > > if (!data) { > > - printf("cannot allocate memory: %zx\n", (size_t)bin_stat.st_size); > > + fprintf(stderr, "cannot allocate memory: %zx\n", > > + (size_t)bin_stat.st_size); > > goto err_1; > > } > > f = fopen(path, "w"); > > if (!f) { > > - printf("cannot open %s\n", path); > > + fprintf(stderr, "cannot open %s\n", path); > > goto err_2; > > } > > header.capsule_guid = efi_guid_fm_capsule; > > @@ -109,7 +110,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, > > > > size = fwrite(&header, 1, sizeof(header), f); > > if (size < sizeof(header)) { > > - printf("write failed (%zx)\n", size); > > + fprintf(stderr, "write failed (%zx)\n", size); > > goto err_3; > > } > > > > @@ -118,13 +119,13 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, > > capsule.payload_item_count = 1; > > size = fwrite(&capsule, 1, sizeof(capsule), f); > > if (size < (sizeof(capsule))) { > > - printf("write failed (%zx)\n", size); > > + fprintf(stderr, "write failed (%zx)\n", size); > > goto err_3; > > } > > offset = sizeof(capsule) + sizeof(u64); > > size = fwrite(&offset, 1, sizeof(offset), f); > > if (size < sizeof(offset)) { > > - printf("write failed (%zx)\n", size); > > + fprintf(stderr, "write failed (%zx)\n", size); > > goto err_3; > > } > > > > @@ -141,17 +142,17 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, > > > > size = fwrite(&image, 1, sizeof(image), f); > > if (size < sizeof(image)) { > > - printf("write failed (%zx)\n", size); > > + fprintf(stderr, "write failed (%zx)\n", size); > > goto err_3; > > } > > size = fread(data, 1, bin_stat.st_size, g); > > if (size < bin_stat.st_size) { > > - printf("read failed (%zx)\n", size); > > + fprintf(stderr, "read failed (%zx)\n", size); > > goto err_3; > > } > > size = fwrite(data, 1, bin_stat.st_size, f); > > if (size < bin_stat.st_size) { > > - printf("write failed (%zx)\n", size); > > + fprintf(stderr, "write failed (%zx)\n", size); > > goto err_3; > > } > > > > @@ -194,7 +195,7 @@ int main(int argc, char **argv) > > switch (c) { > > case 'f': > > if (file) { > > - printf("Image already specified\n"); > > + fprintf(stderr, "Image already specified\n"); > > return -1; > > } > > file = optarg; > > @@ -202,7 +203,7 @@ int main(int argc, char **argv) > > break; > > case 'r': > > if (file) { > > - printf("Image already specified\n"); > > + fprintf(stderr, "Image already specified\n"); > > return -1; > > } > > file = optarg; > > @@ -234,7 +235,7 @@ int main(int argc, char **argv) > > > > if (create_fwbin(argv[optind], file, guid, index, instance) > > < 0) { > > - printf("Creating firmware capsule failed\n"); > > + fprintf(stderr, "Creating firmware capsule failed\n"); > > exit(EXIT_FAILURE); > > } > > >