Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mvN1C-0002es-25 for mharc-grub-devel@gnu.org; Thu, 09 Dec 2021 12:15:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvN17-0002W2-Ji for grub-devel@gnu.org; Thu, 09 Dec 2021 12:15:38 -0500 Received: from [2607:f8b0:4864:20::f2a] (port=46007 helo=mail-qv1-xf2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mvN15-0005E6-Dg for grub-devel@gnu.org; Thu, 09 Dec 2021 12:15:37 -0500 Received: by mail-qv1-xf2a.google.com with SMTP id s9so5646912qvk.12 for ; Thu, 09 Dec 2021 09:15:34 -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=cm+7hd6enUbL0+pQm2xPQVFFJ6Afhw0dW+K/7V5Jbrs=; b=H6EvOXONVQ4kKgdtWyJpw4j9F4/3ypYT3FD2GP12RIp3XkD+dhi6zilAvH6URRBBq4 c0l+UY1dW3wjUTdoqYlPlVn8YtJcRmPcMaC2TRJzzG0+LX9JUDV3wucDqpmDJZEkzsZh e2pw3hnm7Haw+dVxT/YUea+YESJJ1AiFmf74i/0djGFk5T8sX/g94VEy2T5Gg/tgZ65I PpwL3ZJ59Lmd2ouMqYRfEiCYw0xJQ9qDBa5InX6wmV+9S1kZtKpDUeBU+3MXqy2V0Z4B 19QvcsjjS18bCpnu7+tJfL6xi3LZddUZW7tHRfbAqOWdv5mYAtquIhZbdgSoQYaWjXdY ZMsg== 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=cm+7hd6enUbL0+pQm2xPQVFFJ6Afhw0dW+K/7V5Jbrs=; b=gzfjbWwxWG3aEAeZAa7cV1RB2m+uZFpVfCEAxw0Dt5tmxaOhYXjrZsOrPE4d8LVcGD W2UMK9W2LceMKiCA2y30NL7sIUL620HEXYDtwtmTFa32YyIVY3soOG/mgpEkInq6JZfu fXN8KiR/BsICL8hsA0zXDjcRt1uShHWX3LtwxCay7M4N2Dw+uRo+064R5gqWNDIEkKYK hPq5mPghQ4pHsPZmG7DbrLXodvWmZE6cO1EYKilFA0n6nrOVB1jBUtNpyEqVp/vYHtq6 7SvbW6+8xejMqjfc3NAQ3bK/+udJRlbWjN+NiuArWwoEER3OqLMbGW+mXA7uRzPd1ixD siWQ== X-Gm-Message-State: AOAM532GHkY5Fml2Ts1fb8QPY3RChJzlim5Y2rYXDdobVFHco/k+miSE stZ0BJMiNRnPD7yhRt4Onvg4Tw== X-Google-Smtp-Source: ABdhPJz2PZT6+0rIvmPh6uBX/vbGDr5uQvgxjmlupsJ0cNYnTCEn5ngGanXXerXOjK1fns1Glxcbww== X-Received: by 2002:a05:6214:20ee:: with SMTP id 14mr18671552qvk.94.1639070134458; Thu, 09 Dec 2021 09:15:34 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id m9sm151839qkn.59.2021.12.09.09.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 09:15:34 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Denis 'GNUtoo' Carikli , Patrick Steinhardt , James Bottomley , Glenn Washburn Subject: [PATCH v5 9/9] cryptodisk: Improve handling of partition name in cryptomount password prompt Date: Thu, 9 Dec 2021 11:14:58 -0600 Message-Id: <6835aa8667267aa406cae510745c99df3e9d7ee7.1639069499.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::f2a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=development@efficientek.com; helo=mail-qv1-xf2a.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: Thu, 09 Dec 2021 17:15:39 -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 99265097a..2381c3330 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -1021,11 +1021,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