Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4376159pxu; Wed, 9 Dec 2020 15:53:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoKS0CuDiW7ZiakYBF7mb/xVcDKJk4MEbWIh93EYW4kwAA6ACfA5ss7RKlKIRgOc4vZbFi X-Received: by 2002:a17:906:adcb:: with SMTP id lb11mr4013238ejb.346.1607558028290; Wed, 09 Dec 2020 15:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607558028; cv=none; d=google.com; s=arc-20160816; b=Im9qGlrngamZG18w/JI/29gT36zr9Z8eOEIpqAu8vtz5DepdDQ/o2QrskzWlf1Cl6q RASLPSPrShP3jYkwPj9TwA3s/GVYUu7ze0yERsxo/ARFwqIi4TJ/pSpHIYFxqA0fdtWB a9kEWwx24fMjxXUHEUxCVbefQOylEBHU6c6pI1yWRx7V5KbhvhY0wvotDhEUUkel0Lwi GLLpKPOLoIO/I5e/LZU7MmPcM2aiyO7f4yX+N6Hm6bKvu4QsPhv69Lit5scP/QuD3FmW HdiRSoy47r4ZbgzjTEi1/d9kjl11/4mYpBML7YIISqrg3t/fOvrL4FxyvAxbNIjeqCIK JkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:references :subject:cc:to:from:date:user-agent:message-id; bh=JJso7YjN6hK9G9DC5G6bQXvK8hA07ouZEW6dE45SFDs=; b=zS2xro15YuXGSf8xBmkue01BmdeVq8ohdsynqFil4wGzL/1V6uLnKGl+oz28o0ZYIl ZNnvx+hydk7e4Fzdrwm0lsZLg+56Vtf/+sSXvSJNVJl3wY2dw7zfb3sN1qVVDNJWUH1m Yj2QtcBGTZy/G9XW0q390tsggUFTS1hI9rPupEUOridWknYmUq5/ZS1XULGz2CzD3UpD 23m9fk4mvIShI0/jV3yiNV1pEA2HUiEqbPQwubp6QR85T+YB6xD2xUfIDm0zjNkXiXyQ OGNNmwRgfVZPJ6aQdqSvY287uKspF0rBcHKWqJY/V3syT9hJy9aX4abkSZmXogM4uxGb a+0A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si1670419edq.414.2020.12.09.15.53.22; Wed, 09 Dec 2020 15:53:48 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728968AbgLIVOI (ORCPT + 99 others); Wed, 9 Dec 2020 16:14:08 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:49968 "EHLO hera.aquilenet.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731285AbgLIVN5 (ORCPT ); Wed, 9 Dec 2020 16:13:57 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; }