From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752554AbbJFI67 (ORCPT ); Tue, 6 Oct 2015 04:58:59 -0400 Received: from lists.s-osg.org ([54.187.51.154]:47435 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbbJFI65 (ORCPT ); Tue, 6 Oct 2015 04:58:57 -0400 Message-ID: <56138D4E.1070008@osg.samsung.com> Date: Tue, 06 Oct 2015 09:58:54 +0100 From: Luis de Bethencourt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Jiri Kosina CC: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH] HID: hiddev: fix returned errno code in hiddev_connect() References: <1443606749-6028-1-git-send-email-luisbg@osg.samsung.com> <561049F1.5040507@osg.samsung.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/10/15 15:24, Jiri Kosina wrote: > On Sat, 3 Oct 2015, Luis de Bethencourt wrote: > >>> But I am not really sure where you are seeing the bug (mapping to >>> -EPERM) in this case? I think the only caller of hiddev_connect() >>> should be hid_connect(), and the only thing that guy cares about >>> whether individual callbacks succeed or fail, so that it sets >>> hdev->clamed flags accordingly. >>> >>> Could you please be more specific about the -EPERM mapping you are >>> talking about? >>> >> I agree with you. The only caller of hiddev_connect() only checks if the >> callback succeded. It checks if the return < 0. >> What I meant is that -1 means -EPERM. [0] > > I still don't understand what problem you are chasing here, sorry. EPERM > is defined to be 1, yes. So are many other completely unrelated #defines. > >> This patch is purely about the correctness of using -ENOMEM. The word >> "propagated" was not the best way to describe this problem. I could edit >> the commit message if you would like. > > You seem to imply that someone might be interpreting that -1 as a define > from errno.h. But that's not the case. > > Are you going to look at every 'return -1' occurence in the kernel and > convert it to something else? That can keep you busy for quite some time: > > $ git grep 'return -1' | wc -l > 9167 > > The only cleanup I'd imagine at least remotely possible in this case would > be to convert the ->connect() callbacks return bool. > This is a very good point. I will write a second version of the patch that converts the return to a boolean. Thanks for the review, Luis