From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB17C433ED for ; Fri, 23 Apr 2021 14:47:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9043861462 for ; Fri, 23 Apr 2021 14:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbhDWOs2 (ORCPT ); Fri, 23 Apr 2021 10:48:28 -0400 Received: from mail.javad.com ([54.86.164.124]:45868 "EHLO mail.javad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbhDWOs0 (ORCPT ); Fri, 23 Apr 2021 10:48:26 -0400 X-Greylist: delayed 449 seconds by postgrey-1.27 at vger.kernel.org; Fri, 23 Apr 2021 10:48:26 EDT Received: from osv (unknown [89.175.180.246]) by mail.javad.com (Postfix) with ESMTPSA id 905303E95C; Fri, 23 Apr 2021 14:40:20 +0000 (UTC) Received: from osv by osv with local (Exim 4.92) (envelope-from ) id 1lZwyh-0004QE-7K; Fri, 23 Apr 2021 17:40:19 +0300 From: Sergey Organov To: Walter Harms Cc: David Laight , 'Dan Carpenter' , Joel Stanley , Andrew Jeffery , "Chia-Wei, Wang" , Jae Hyun Yoo , "John Wang" , Brad Bishop , Patrick Venture , "Benjamin Fair" , Greg Kroah-Hartman , Robert Lippert , "linux-aspeed@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Subject: Re: AW: [PATCH] soc: aspeed: fix a ternary sign expansion bug References: <59596244622c4a15ac8cc0747332d0be@AcuMS.aculab.com> <877dktuvmz.fsf@osv.gnss.ru> <265e2d3accc74c89b5bab22eadb43808@AcuMS.aculab.com> Date: Fri, 23 Apr 2021 17:40:19 +0300 In-Reply-To: (Walter Harms's message of "Fri, 23 Apr 2021 11:03:30 +0000") Message-ID: <878s59rrn0.fsf@osv.gnss.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Walter Harms writes: > as indepentent observer, > i would go for Dans solution: > > ret = kfifo_to_user(); > /* if an error occurs just return */ > if (ret) > return ret; > > /* otherwise return the copied number of bytes */ > > return copied; > > there is no need for any deeper language knowledge, Yep, but this is not idiomatic C, so one looking at this code would tend to convert it back to ternary, and the actual problem here is that the type of 'copied' does not match the return type of the function. -- Sergey Organov