From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [PATCH v4 6/6] iio:bmi160: use if (ret) instead of if (ret < 0) References: <20190202215601.20275-1-martin@martingkelly.com> <20190202215601.20275-7-martin@martingkelly.com> From: Martin Kelly Message-ID: Date: Sat, 2 Feb 2019 16:30:44 -0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit To: Fabio Estevam Cc: linux-iio@vger.kernel.org, Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Daniel Baluta , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" List-ID: On 2/2/19 3:12 PM, Fabio Estevam wrote: > On Sat, Feb 2, 2019 at 7:59 PM Martin Kelly wrote: >> >> From: Martin Kelly >> >> We are using "if (ret < 0)" in many places in which the function returns 0 >> on success. Use "if (ret)" instead for better clarity and correctness. > > What's wrong with "if (ret < 0)" ? > Jonathan Cameron pointed out that the check is for functions that return 0 on success. Thus, the check should be either "if (ret != 0)" or "if (ret)". Jonathan prefers "if (ret)", so I'm using that. By leaving it at "if (ret < 0)", technically a function could return positive numbers and not count as an error, which is a bug.