From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id C7BF9380FBF; Wed, 9 Dec 2020 16:13:45 -0500 (EST) Received: from hera.aquilenet.fr (hera.aquilenet.fr [185.233.100.1]) by befuddled.reisers.ca (Postfix) with ESMTPS id 5C818380F8E for ; Wed, 9 Dec 2020 16:13:45 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id D81B81309; Wed, 9 Dec 2020 22:13:12 +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 sqEjnCBbjJ_5; Wed, 9 Dec 2020 22:13:12 +0100 (CET) Received: from function.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7]) by hera.aquilenet.fr (Postfix) with ESMTPSA id D2DDEC80; Wed, 9 Dec 2020 22:13:10 +0100 (CET) Received: from samy by function.youpi.perso.aquilenet.fr with local (Exim 4.94) (envelope-from ) id 1kn6lq-006kOS-4x; Wed, 09 Dec 2020 22:13:10 +0100 Message-Id: <20201209205838.672084780@ens-lyon.org> User-Agent: quilt/0.65 Date: Wed, 09 Dec 2020 21:58:32 +0100 From: samuel.thibault@ens-lyon.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org, Samuel Thibault Subject: [patch 3/3] speakup: Simplify spk_ttyio_out error handling. References: <20201209205829.693745475@ens-lyon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=spk_ttyio_clean X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2020 21:13:45 -0000 This avoids most code indentation Signed-off-by: Samuel Thibault Index: linux-5.10/drivers/accessibility/speakup/spk_ttyio.c =================================================================== --- linux-5.10.orig/drivers/accessibility/speakup/spk_ttyio.c +++ linux-5.10/drivers/accessibility/speakup/spk_ttyio.c @@ -225,27 +225,29 @@ void spk_ttyio_unregister_ldisc(void) static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) { struct tty_struct *tty = in_synth->dev; + int ret; - if (in_synth->alive && tty->ops->write) { - int ret = tty->ops->write(tty, &ch, 1); + if (!in_synth->alive || !tty->ops->write) + return 0; - if (ret == 0) - /* No room */ - return 0; - if (ret < 0) { - pr_warn("%s: I/O error, deactivating speakup\n", - in_synth->long_name); - /* No synth any more, so nobody will restart TTYs, - * and we thus need to do it ourselves. Now that there - * is no synth we can let application flood anyway - */ - in_synth->alive = 0; - speakup_start_ttys(); - return 0; - } + ret = tty->ops->write(tty, &ch, 1); + + if (ret == 0) + /* No room */ + return 0; + + if (ret > 0) + /* Success */ return 1; - } + pr_warn("%s: I/O error, deactivating speakup\n", + in_synth->long_name); + /* No synth any more, so nobody will restart TTYs, + * and we thus need to do it ourselves. Now that there + * is no synth we can let application flood anyway + */ + in_synth->alive = 0; + speakup_start_ttys(); return 0; }