Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3974046pxt; Tue, 10 Aug 2021 16:23:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwibrtuIK79aF9MCCPtkU+KgM/lwqh9VfOwI3Nhkd2ah7/wGkaeU9hHEIEDSczBPJdCKVfT X-Received: by 2002:a05:6402:1289:: with SMTP id w9mr7823266edv.127.1628637783125; Tue, 10 Aug 2021 16:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628637783; cv=none; d=google.com; s=arc-20160816; b=0tshz0UMQVvAliMXTxjnCxy3yKMWs358jIiC+FyNjKdyf8bkI6pVKJ/WRSj6iXotIA BzI/IiapaVr1eEM66eFOqksJiDDagwRg0X4OlcxrG3678MO9KXxQJn9r2jhm9P1jtIJX ZedPRpSd4bpk8SXKrpPKEiE0AFJWYW2c+RrR51lktf2k3mu+jhc0CbZRLG1CaJPyPNtV prYtqF9qVAM0CAVdfpxDNUurM8xSiHmQfzCYLYSp4iJ4NCFiSaFt3S4Flct3DqH8HbDO Cm0up4It8MWrPm/HBj6VSBRU7NMBhS40wzIB3BcoYChf5/cCZNrpEXGocRPofrsnubKk 3cLg== 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=yCA36GlhulzbAlvlHtt61ilkxjPVScFxCkohpC2ykWk=; b=wuA0ymK+ewxBOV3uGmfl0RiJS0HXtguMZGx8USb3sjzh/qldcHziOOI/V2iZ3Azp98 9fGYWzmx8+DIqVjCIec9WeDZKyDTkRvO7ixTHBcyGxYY/e3F6Gfg5QiYr5bp8yOYNPc8 yHIynwC0k9IGcKIbnrTY5vhgCZao9KtTxnLDqfE35N5aJ8IKLeHE/jFpB9Eqda0Bu8Wb SGpRZFH0pe5QaBRcnCw13NLlnx+dANTcqsRqolxeQyNgHLnxgXH7SDARgryDuzpIkWnz LHNe2wBB/OSLFxpby7KNSIjThuvFgiFAiaSPQHjBmoApjOfg6Q7xbvVb0lIKC7DOLg84 t/tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FTA5YoMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb13si24628701edb.420.2021.08.10.16.22.39; Tue, 10 Aug 2021 16:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FTA5YoMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235332AbhHJXTh (ORCPT + 99 others); Tue, 10 Aug 2021 19:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235258AbhHJXTg (ORCPT ); Tue, 10 Aug 2021 19:19:36 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17711C061765 for ; Tue, 10 Aug 2021 16:19:14 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id t3so133983plg.9 for ; Tue, 10 Aug 2021 16:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yCA36GlhulzbAlvlHtt61ilkxjPVScFxCkohpC2ykWk=; b=FTA5YoMorv370+N11Fvss0cbmgz8Dj0PUif6S7Mxwx4JFXKANXI2ABB1FsnT+o0aO7 +2dmeWORjkoqKFVsB7/Qw6zRG/TQvMbVNiCXYy0hSkThjr1EZ39RPTNvShGWWI4kIWlw PQ5+QQnfLZVsH+kO/8KgAqDvSSZi0nd73MhtbXiSqDsZV1SW/nAK2uc+p76eAMgF5a2k Bh9h8RSzV0hSHuEA/rD5vjlvsiWxHlfme1acpRBbJeZYXHI831TMqbpR1O34+IhbXfBc naKZQ3GprWfaZMjIFowhjAFkoqnRgjzOPHc3nKdkiX9e0ox6fsr/OSMedr37X0R/wK/R hfVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yCA36GlhulzbAlvlHtt61ilkxjPVScFxCkohpC2ykWk=; b=oHqxaHQwceY1yXcn6LGQh/5yLEqcinnRX/Qf5v0clAj2ujPaaIim6fMTGudwpvzBsq /CcDj6scwY4JSH102BAuslVb9AmDWqC+9uYVmOSkrppfdA1u36rgZAiqbtS+boOv8uzm OuZw/rKF7V3Ye50IuLFwn35xmtcBik6z1INhshHPZH8FAUQw/suTmzzdFMhPkM/a1qKb Cj7b5EC/l6q3mvK2bf9HMy3B7YstwvKolyOd+k8RU1BTIJTem4BdPmZmUwjiKlrxINyi Zeuos2KIM41c5IlQLmBwVDclwqT95VnM5Zjc/vNksnZM5e1JbIFgJwBdqFIKR6FpAsih rp7Q== X-Gm-Message-State: AOAM5304tffxW2Tn3cdkNvt45AOZvboIaOTNGHDf45h39KW2+Ji+PdPV cAWozSwNuv0BDsjdCpdIX4x7+Dtkdbc= X-Received: by 2002:a17:90b:3d8:: with SMTP id go24mr7433529pjb.235.1628637553712; Tue, 10 Aug 2021 16:19:13 -0700 (PDT) Received: from octofox.metropolis ([172.56.38.87]) by smtp.gmail.com with ESMTPSA id dw15sm23117348pjb.42.2021.08.10.16.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 16:19:13 -0700 (PDT) From: Max Filippov To: linux-xtensa@linux-xtensa.org Cc: Chris Zankel , linux-kernel@vger.kernel.org, Max Filippov , Abaci Robot , Jiapeng Chong Subject: [PATCH] xtensa: ISS: don't use string pointer before NULL check Date: Tue, 10 Aug 2021 16:19:03 -0700 Message-Id: <20210810231903.5778-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move strlen call inside the if block that checks string pointer for NULL. While at it also fix the following coccicheck warning: ./arch/xtensa/platforms/iss/console.c:204:10-11: WARNING comparing pointer to 0. Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong Signed-off-by: Max Filippov --- arch/xtensa/platforms/iss/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index a3dda25a4e45..8f41c0088220 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -193,10 +193,10 @@ late_initcall(rs_init); static void iss_console_write(struct console *co, const char *s, unsigned count) { - int len = strlen(s); - - if (s != 0 && *s != 0) + if (s && *s != 0) { + int len = strlen(s); simc_write(1, s, count < len ? count : len); + } } static struct tty_driver* iss_console_device(struct console *c, int *index) -- 2.20.1