Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2995780lqo; Tue, 14 May 2024 16:49:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2BSkiKBxYnroJm1wKjit4FgefGHex6HGr41vwT8qdomWFmFC/3QTd/HJzrf67qJpnEIfmV2S0GeXzJS7djsMDvUnRqLot835/isGFzw== X-Google-Smtp-Source: AGHT+IE4u/LYnNOCklBL3zeQvkWCOXHG/AWgs15Oovd6txtW7tZLGTSSUxftVp5UqjAhoRjJ/ZKa X-Received: by 2002:a05:620a:1129:b0:792:c10c:dc82 with SMTP id af79cd13be357-792c7574a13mr1603863785a.7.1715730584315; Tue, 14 May 2024 16:49:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715730584; cv=pass; d=google.com; s=arc-20160816; b=eoeO3syR0VHapa2FBBNu/+fKwK6oM/XU1IAeRp56q9Qfd2hszmFOCNa8rG/M9XCCYe +FVLvF9Qvl5JQCw59EU8p8thAmBkpCX5spwAZKps07PLqvMekMFIfuG5piim7UN36a4w M575h86UsKTJp/jHIGG/xN+ArYf7a32Bab2p450ug+R2SWdGHQKTQFC0gajxXCONv2og egK490GU5dLIp7CNY+A+gyZX+uiUY4Ya6Cei2WpoobNjj5vgfIwRtmupDVXbwB3ae6rZ ARdk65knP0o0w0QmBnw/QUGxTIKC4qkF0dOET3dYsllrqFS8how+/xXvFnd4qypU7NEw TFAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date; bh=r+cSyGGrjhCELZnXIQ0ol2Y9riqj80dNtC+lxXbMvpo=; fh=vtlNkVyRFlGyG2yvBKbTZD/xAqolSDUbWM7DMGl4NMU=; b=P3tH7qSXwDp2T/dA4Sx0yj7v90HkI13+lns5c7SNr77hCXGiFqEWFdZfjnfiGRiXaU ZfZUIMOmHhB9CsQd3XLkPpKMgaT1QaY8mXUQtz2+6i8NNf+ptV45bF9kZ8LL3xHpMv6m 3x1DCQ0YWWJYklrqRNE97xBtDCuaAKlk1pw/PKdrg9dWWsK4ebDSTwoXij+5eztO1+En mAScFxXwh8ja9WboHpOeyhX983tjw29VUtAc0Gi9CmrRXY/1GohGRz8ZRoq4vc1fmoNH 6pQ3wQhtnZI9xZsW/7jaG/hHSbvAXvL7jAWiW8cTHyWzXDjEq7hXR8wj1qSd/JTn6VlH wY7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-179269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179269-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf277a92si1274740785a.29.2024.05.14.16.49.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 16:49:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-179269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179269-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EAA721C20D94 for ; Tue, 14 May 2024 23:49:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 419FF182CA7; Tue, 14 May 2024 23:49:37 +0000 (UTC) Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 612841E491; Tue, 14 May 2024 23:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.133.224.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715730576; cv=none; b=MnCEU1Eba+gFqvyRtGL3jQ6SpuT84qKHHXu2ZZXmFHMZGekgU6zGZgecZDa52ztjuuvHgpKfvc2JhwMqhS12zj9AciSqjaIQgQRyr9NJelERrNHXJn9jD0svrxQkzwI4ETjsn5Xaoqvz6QTQF9P7S53HgV1k6jE8eDL/fXHSBl0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715730576; c=relaxed/simple; bh=qbv3bhwyolQ2fa4CHsQpjgG2qUfpyh+slSW4CMlvmwU=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=u/mSud9hkSORck18V5YeF1I7NtHI8N8PXovP1MgWDoXuZ8JTgjpLrx22+CvKRhD8Ez3BKBZqzG5XOQgFvbsKYbfALuN5XNfHe8a17en6xHM9HbsGPyPwsL6PyZrb5V07Ow3mTMz/8MlOurTt6aFvaIWTFil9FqPZV89mL3eA5VQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk; spf=none smtp.mailfrom=orcam.me.uk; arc=none smtp.client-ip=78.133.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=orcam.me.uk Received: by angie.orcam.me.uk (Postfix, from userid 500) id 84BC592009C; Wed, 15 May 2024 01:49:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 7EB5A92009B; Wed, 15 May 2024 00:49:31 +0100 (BST) Date: Wed, 15 May 2024 00:49:31 +0100 (BST) From: "Maciej W. Rozycki" To: Joe Perches cc: Thomas Bogendoerfer , linux-mips@vger.kernel.org, LKML Subject: Re: sibyte: pointless if tests In-Reply-To: <2cf0b77f51b907969ae83993854773961b4e159c.camel@perches.com> Message-ID: References: <2cf0b77f51b907969ae83993854773961b4e159c.camel@perches.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Sat, 24 Feb 2024, Joe Perches wrote: > Here are a couple in sibyte: > > Maybe this should be documented as: > > "well, don't know what to do here" Of course just removing these useless conditionals isn't going to help here because if a console write does fail for some reason, then the index will move backwards regardless. At least we now have some kind of a placeholder to bring someone's attention (such as yours). > $ spatch --very-quiet -sp-file if_semi.cocci . > diff -u -p ./arch/mips/sibyte/common/cfe_console.c /tmp/nothing/arch/mips/sibyte/common/cfe_console.c > --- ./arch/mips/sibyte/common/cfe_console.c > +++ /tmp/nothing/arch/mips/sibyte/common/cfe_console.c > @@ -22,8 +22,6 @@ static void cfe_console_write(struct con > if (str[i] == '\n') { > do { > written = cfe_write(cfe_cons_handle, &str[last], i-last); > - if (written < 0) > - ; > last += written; > } while (last < i); > while (cfe_write(cfe_cons_handle, "\r", 1) <= 0) The author indeed clearly was undecided as to what to do as the full last statement here is actually: while (cfe_write(cfe_cons_handle, "\r", 1) <= 0) ; potentially looping indefinitely. The CFE API clearly says: Error codes: Code Description CFE_ERR_INV_PARAM File handle is invalid others Device may return device-specific error codes and maybe CFE never actually fails for a console device write (I'd have to check the sources if there are any "others" for the console device and I'd assume the console file handle is always valid), but IMO the safe approach would be just to chicken out and silently return on a failure from any of these calls. Also this code has been oddly written IMO and would benefit from some refactoring. I'll see if I can queue a patch. Maciej