Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mtPHy-00044X-1N for mharc-grub-devel@gnu.org; Sat, 04 Dec 2021 02:16:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mtPHw-00042Q-DK for grub-devel@gnu.org; Sat, 04 Dec 2021 02:16:52 -0500 Received: from [2607:f8b0:4864:20::829] (port=36806 helo=mail-qt1-x829.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mtPHv-0005Mf-09 for grub-devel@gnu.org; Sat, 04 Dec 2021 02:16:52 -0500 Received: by mail-qt1-x829.google.com with SMTP id t11so5759699qtw.3 for ; Fri, 03 Dec 2021 23:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3O2TsIJR1+sATbkcgjSUruZMQ/SV2D86drRKZwU+/8M=; b=kpCxLcj4JZg3d4V/Xv1790WgMAZTkDdEZV4LGqPsYY3LeqiJEVWyFNqV3et0bPZGrT krrMUvvT/pBlTZApcu1KbpRiJVS45W5R4cmMXLF0XYNcF4Qlc0u0yxaB/1co/qzxNhyD 17EvbrPdiOPW7aVVBqyXW/MwP/Ue0twcB6003m2V2kAjr/rxNRD2nwiqjeyAQgni8XXv C56jDgHNSnVsLgBgHnfftBKoZvf8WJbdaIckXziBkn4VBetgDh8rq197DaFBfGs4TNfi bodB1GDb36ONFsNiN3YU9UzQRisizgcE9IM+BV+9kuDJ3oWxOzNguRf3MG6igF3rUBP5 updg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3O2TsIJR1+sATbkcgjSUruZMQ/SV2D86drRKZwU+/8M=; b=B0nyrxTC5ZJqVEddU16WfFPxFmskXewSmCyZ0pwwm1DQHGTxOYst/VPemzeTyVEyG2 U8IqWLq/WSB0ZFzxq2EOobWE2SKWUjSJDxunv9kTtwmoPP1tC9MecikP7gLNkGvyVtS+ lZ8mKE6oQcQGWwtDGx06sBAOobuJUg5mycWjZAP339Gw1svs3R+YbB5Lpzpt1YJLgvbs 3BXhCTKkcLR4zMGj1i5a5w9RlmKWa6cCHYP4fgTfWagiS7+KD2qnkEbFyuaDFwnQWjjt m9S3trU7fb4H4sy1EKqlpqiBW0VPaYfoENqDVN3wXlTy2cJR0CmwN/RyEh04/J0faML2 AYyQ== X-Gm-Message-State: AOAM530NcjdvZucrzZ0SakoszkNFUuZkugtGdeoXGc0uclKl6UJlYlo4 3Con0W1Q+MRj20ir4X0s9wPGaA== X-Google-Smtp-Source: ABdhPJzzG5qHvVsv6+uugTqhKbw8pyjEpvnVp98EcxjBIF1/gUD8NYSKLGdmEYRDKJJSpPP639aeNA== X-Received: by 2002:a05:622a:5cd:: with SMTP id d13mr25936936qtb.361.1638602210234; Fri, 03 Dec 2021 23:16:50 -0800 (PST) Received: from localhost.localdomain (garza.riseup.net. [198.252.153.109]) by smtp.gmail.com with ESMTPSA id bs16sm3765382qkb.45.2021.12.03.23.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 23:16:49 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Denis 'GNUtoo' Carikli , Patrick Steinhardt , James Bottomley , Glenn Washburn Subject: [PATCH v4 7/7] cryptodisk: Improve handling of partition name in cryptomount password prompt Date: Sat, 4 Dec 2021 01:15:50 -0600 Message-Id: <40a6f2d1bbda0ae0171f39488c0635565649ad08.1638601099.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::829 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=development@efficientek.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Dec 2021 07:16:52 -0000 Call grub_partition_get_name unconditionally to initialize the part variable. Then part will only be NULL when grub_partition_get_name errors. Note that when source->partition is NULL, then grub_partition_get_name returns an allocated empty string. So no comma or partition will be printed, as desired. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index ad08240ff..d50b3033e 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -1026,11 +1026,10 @@ grub_cryptodisk_scan_device_real (const char *name, { /* Get the passphrase from the user, if no key data. */ askpass = 1; - if (source->partition != NULL) - part = grub_partition_get_name (source->partition); + part = grub_partition_get_name (source->partition); grub_printf_ (N_("Enter passphrase for %s%s%s (%s): "), source->name, source->partition != NULL ? "," : "", - part != NULL ? part : "", + part != NULL ? part : N_("UNKNOWN"), dev->uuid); grub_free (part); -- 2.27.0