Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp139314pxb; Mon, 7 Feb 2022 08:02:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwM8Fjcc2rqSjZ4+7/oCmKMgVipkD1uWp77CZ3PT67hgbGB5Xc6wuk1eJS5dYxF5vNZ+DzT X-Received: by 2002:a05:6402:448c:: with SMTP id er12mr136617edb.137.1644249761096; Mon, 07 Feb 2022 08:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644249761; cv=none; d=google.com; s=arc-20160816; b=cRjVJCN8gVggvMxjCNea+y1vpf8L1GA8POB+gkRnUaKPx6hFObZExR0rqQGABqugLs zvVhIBC82TNOB80wSJSWesGMe7vEqDoQMygX+RrzCYV0WF1LqxQLSmQ/S9qJZwdGpuvp ynfQy3tAxR67KFQAqAGn7WPpRUmOx43Pq1LdGNqp1k2+O2oSIk3rVaYkXOw7xhd7vYAV tBwwOoCxoAMQE+ulb4JY0XqAO0/4CjSmp4x8mCjkcYTMluI0Q3SnzqFv9DbWp7u5pUOH T9rrGpWU3IfXLxkcdQMU4+gjai9RjblGTr/bKTjLT07e5qUJ6Gwp5AoDwR6PoPPTeND1 w+Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :mail-followup-to:message-id:subject:cc:to:from:date; bh=J6Z+c55nRQDF23wsPu4Vj3nXW00lI4k/0kAi086fIQg=; b=ofaVtiMO8RmivRKw6GRpMFUvDX5PaFTKYykDaef3XUJDiWeGrxycXGzopyWQX2OQCp GkvmXTpedazxRLyaQ8JoIJ/bTT0mlCWDTOtRjxkuh9OxTIQNhYN1kYtnaQV2SBD62dWa 1Gp9Zlr2DeTBBcxV7nk901uIQCSQUe0RwzbAVnmCoaRh5phxWP+tSuLtV/17WBQdL1um 4QnfMfKnhz+6Ud1QTjoGMcrPy7G0mC6+gtSSC5uVUqkYPOPqh5poPKhTJLJtcw879ENn 3920FkhN/1ikvIymVss0Sktq8zTwYpWnWlQ5KRNUWSTloI/AKco+ixjdO3tfS9MUliha fjdA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga6si2266572ejc.273.2022.02.07.08.02.15; Mon, 07 Feb 2022 08:02:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbiBFCiu (ORCPT + 99 others); Sat, 5 Feb 2022 21:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiBFCit (ORCPT ); Sat, 5 Feb 2022 21:38:49 -0500 Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD444C043186 for ; Sat, 5 Feb 2022 18:38:48 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 595B592; Sun, 6 Feb 2022 03:38:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5AZt1-6-iP0a; Sun, 6 Feb 2022 03:38:46 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 92E42203; Sun, 6 Feb 2022 03:38:46 +0100 (CET) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nGXRt-000Gzf-LC; Sun, 06 Feb 2022 03:38:45 +0100 Date: Sun, 6 Feb 2022 03:38:45 +0100 From: Samuel Thibault To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org Subject: [PATCH] speakup_audptr: cleanup synth_version Message-ID: <20220206023845.bpzxtjohekclffra@begin> Mail-Followup-To: Samuel Thibault , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, speakup@linux-speakup.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) X-Spamd-Bar: / Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Server: hera X-Rspamd-Queue-Id: 595B592 X-Spamd-Result: default: False [0.40 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; TO_DN_NONE(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_THREE(0.00)[3] X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no 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 The buffer was bigger than necessary, and the while loop not very canonical. Also better use i as variable name for an index. Reported-by: kernel test robot Suggested-by: Dan Carpenter Signed-off-by: Samuel Thibault --- .../accessibility/speakup/speakup_audptr.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/accessibility/speakup/speakup_audptr.c b/drivers/accessibility/speakup/speakup_audptr.c index e89fd72..a0c3b8a 100644 --- a/drivers/accessibility/speakup/speakup_audptr.c +++ b/drivers/accessibility/speakup/speakup_audptr.c @@ -126,20 +126,22 @@ static void synth_flush(struct spk_synth *synth) static void synth_version(struct spk_synth *synth) { - unsigned char test = 0; - char synth_id[40] = ""; + unsigned i; + char synth_id[33]; synth->synth_immediate(synth, "\x05[Q]"); - synth_id[test] = synth->io_ops->synth_in(synth); - if (synth_id[test] == 'A') { - do { - /* read version string from synth */ - synth_id[++test] = synth->io_ops->synth_in(synth); - } while (synth_id[test] != '\n' && test < 32); - synth_id[++test] = 0x00; + synth_id[0] = synth->io_ops->synth_in(synth); + if (synth_id[0] != 'A') + return; + + for (i = 1; i < sizeof(synth_id) - 1; i++) { + /* read version string from synth */ + synth_id[i] = synth->io_ops->synth_in(synth); + if (synth_id[i] == '\n') + break; } - if (synth_id[0] == 'A') - pr_info("%s version: %s", synth->long_name, synth_id); + synth_id[i] = '\0'; + pr_info("%s version: %s", synth->long_name, synth_id); } static int synth_probe(struct spk_synth *synth) -- 2.34.1