Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1731250rwb; Thu, 8 Dec 2022 14:40:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EtVjeYfFyA4UdA9OOnvCQ7SU3eI7x7BazdPVlgoay5XdsdvayHulaSwy8TfCfULlpU2zH X-Received: by 2002:a17:906:2898:b0:7ad:a350:7fd9 with SMTP id o24-20020a170906289800b007ada3507fd9mr3149926ejd.52.1670539247846; Thu, 08 Dec 2022 14:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670539247; cv=none; d=google.com; s=arc-20160816; b=NP0TayJqdmbX6c4YACvcizVKsBb2qzcAp8G5T8arhOhGxSxzXtcNkItDZoMddplL8Q 5PrlJxSteUxECJZ3Bwt4uvqyi/YTITtk2WjBiIzRj/T72pqRKeewVP4txECezxaX5NXn kfKaipWgBpNQ6ahSS0vsdMBW+5mL0WEFfvCFvJyAu1l1USeolacs53wzAWeXKwmvnBGC dkVFXPl43TwnbyaXTLO2YeK3kXExf3rudNuQeSlNoRwP84OgV60A/tinQZ3Hbf4KxYf7 T2eLf+9Oo+lzFbIkefg/0H99unWjiVlP5DGd33X7cMNTMz+QsATI47GrDS9MyMQP/6s0 9x8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ofafQVLNRP+tT6wQKp30O09XbJPTUTpdSmZSfMnZHZ4=; b=BTOiTD//BjJ46VqlSFfsT4P17MD3li/FAK23uINUDTJ/1XJ0uwbKd3tSVSiapH2HiJ BOR+fyiQG+NAI7bbv8STWkh89fCZIhsYjCGUNLlXT5xyWhTHgzgXZzCujrqoWJL9sIa9 guzZs9lRbg9zyAI5nVpnjwWhhLAylgr6aDJ8uUEalknfJjs/kabUMKPMDBO29serKJk/ XFprQmf+a9gFL30jpZY6V9bju4iQmR+YPZcgNT3FMO1ACGQ7ORxsuLs38vmoVAGg5QFF z5gL9j0uqEaVxD3yyPY5xUPtay3ckLIcJMvSWPMHUuPBnymjR/rvK1LZVDJr10aj2Mrm vjuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Yy0XwLfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd17-20020a1709069b9100b007c0cb833625si14888161ejc.478.2022.12.08.14.40.29; Thu, 08 Dec 2022 14:40:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Yy0XwLfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbiLHWMO (ORCPT + 73 others); Thu, 8 Dec 2022 17:12:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbiLHWMC (ORCPT ); Thu, 8 Dec 2022 17:12:02 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA4B63A2; Thu, 8 Dec 2022 14:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670537519; x=1702073519; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fT9SC06qYKXjgX1+neHHzXyWOTyqrcFvQQcpAYrJp80=; b=Yy0XwLfCQb+8JabfVdvKKykzMimJkBKgaOM7fSGck+IN3nSQfPupa6YE v9/5JFzVZcgHrW2krsSQDtdMs10ezIa0/f6ZC1dJJNqbiCYB9Hdp+l+X6 oogk+Aqs2TxE/InZzQDePDU8Q53SVzfJg2NB744kFnM7AEFDddNPDPfWs 9H4FJPloRH3gJ1vbUNLsiaVXhH8mCDKq4hHTGqcmyIsMhskuk8yJ5u415 4z/7NsSIkOJy55OMF7oNL0dgUQuGZFtXRFJv4ZwTHk8rs13kZc/UzB3SM gihe0UH46PKT6HuGsHFVBsEVIEiCgW+o5ifzQb1Jug+6fHE69u50k+FFC A==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="300735866" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="300735866" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 14:11:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="649335504" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="649335504" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 08 Dec 2022 14:11:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D63CC179; Fri, 9 Dec 2022 00:12:23 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Hans de Goede , platform-driver-x86@vger.kernel.org Subject: [PATCH v1 1/2] efi/earlycon: Replace open coded strnchrnul() Date: Fri, 9 Dec 2022 00:12:16 +0200 Message-Id: <20221208221217.56354-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strnchrnul() can be called in the early stages. Replace open coded variant in the EFI early console driver. Signed-off-by: Andy Shevchenko --- drivers/firmware/efi/earlycon.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c index 4d6c5327471a..be7c83b6cd10 100644 --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -143,16 +144,10 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num) len = si->lfb_linelength; while (num) { - unsigned int linemax; - unsigned int h, count = 0; + unsigned int linemax = (si->lfb_width - efi_x) / font->width; + unsigned int h, count; - for (s = str; *s && *s != '\n'; s++) { - if (count == num) - break; - count++; - } - - linemax = (si->lfb_width - efi_x) / font->width; + count = strnchrnul(str, num, '\n') - str; if (count > linemax) count = linemax; -- 2.35.1