From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbbJEHnk (ORCPT ); Mon, 5 Oct 2015 03:43:40 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:61438 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbbJEHni (ORCPT ); Mon, 5 Oct 2015 03:43:38 -0400 X-AuditID: cbfec7f4-f79c56d0000012ee-f4-56122a286f36 Subject: Re: [PATCH 14/19] sony-laptop: fix handling sony_nc_hotkeys_decode result To: Darren Hart References: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> <1443103227-25612-15-git-send-email-a.hajda@samsung.com> <20151003163932.GB110874@vmdeb7> Cc: linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz , Marek Szyprowski , Mattia Dongili , platform-driver-x86@vger.kernel.org From: Andrzej Hajda Message-id: <561229FD.9010308@samsung.com> Date: Mon, 05 Oct 2015 09:42:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-version: 1.0 In-reply-to: <20151003163932.GB110874@vmdeb7> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xq7oaWkJhBl9WMltsnLGe1aJroYHF 5V1z2CzWHrnLbvHq6mo2i9V7XjA7sHlsXqHl0bZ8H4tH35ZVjB6fN8kFsERx2aSk5mSWpRbp 2yVwZWx7s5ax4JZExZ5tq1kbGK8KdzFyckgImEicfHmbHcIWk7hwbz0biC0ksJRRor9BuouR C8h+zihxavkGsCJhgRCJzxt+sYDYIgJqEvuW3GWBKFrIKLGv7wAziMMscIlRYurEV4wgVWwC mhJ/N98EG8sroCXxensfWDeLgKrEn/WTwOKiAhESp86+haoRlPgx+R5YDaeArkT/sglANgfQ UD2J+xe1QMLMAvISm9e8ZZ7AKDALSccshKpZSKoWMDKvYhRNLU0uKE5KzzXUK07MLS7NS9dL zs/dxAgJ5i87GBcfszrEKMDBqMTDeyBeMEyINbGsuDL3EKMEB7OSCO/r/0Ah3pTEyqrUovz4 otKc1OJDjNIcLErivHN3vQ8REkhPLEnNTk0tSC2CyTJxcEo1MGbpLehUCD/S5+Gl/3Sma55y 2W6Z/Rqfl8ZHuZiEHv7UpCKsM4OxwUng7Kbrt3SvBS/rErywsXqtvfTsTWWBu9fPjJiVxhF2 +8OPdWv/tGUcnJB/oFrnx7Pg3RpHv96U6A449zre5eL3PSbBPNKLHyrvf/wujlVz29uolaXX LGcbnwv4GMbFlKDEUpyRaKjFXFScCADVE8ScYgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/03/2015 06:39 PM, Darren Hart wrote: > On Thu, Sep 24, 2015 at 04:00:22PM +0200, Andrzej Hajda wrote: >> The function can return negative value. >> >> The problem has been detected using proposed semantic patch >> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. >> >> [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 >> >> Signed-off-by: Andrzej Hajda > Sorry for the delay Andrsej, and thank you for your patch. Given my delay, I've > made a couple of changes myself rather than asking you to resubmit. Please > review and let me know if you have any concerns. Looks OK. Thanks for fixing. Regards Andrzej > > First, The description above is incomplete and relies on context from the URL > to fully explain the problem you are fixing. In the future, please ensure the > commit message is self-sufficient. > > I have changed the message to read: > > sony-laptop: Fix handling sony_nc_hotkeys_decode result > > sony_nv_hotkeys_decode can return a negative value. real_ev is a u32 variable. > The check for real_ev > 0 is incorrect. > > Use an intermediate ret variable. > > The problem has been detected using proposed semantic patch > scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. > > [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 > > Signed-off-by: Andrzej Hajda > [dvhart: clarify commit msg, drop superfluous else block] > Signed-off-by: Darren Hart > > See below for an additional change. > >> --- >> Hi, >> >> To avoid problems with too many mail recipients I have sent whole >> patchset only to LKML. Anyway patches have no dependencies. >> >> Regards >> Andrzej >> --- >> drivers/platform/x86/sony-laptop.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c >> index aeb80d1..d8a2115 100644 >> --- a/drivers/platform/x86/sony-laptop.c >> +++ b/drivers/platform/x86/sony-laptop.c >> @@ -1204,6 +1204,8 @@ static void sony_nc_notify(struct acpi_device *device, u32 event) >> { >> u32 real_ev = event; >> u8 ev_type = 0; >> + int ret; >> + >> dprintk("sony_nc_notify, event: 0x%.2x\n", event); >> >> if (event >= 0x90) { >> @@ -1225,13 +1227,15 @@ static void sony_nc_notify(struct acpi_device *device, u32 event) >> case 0x0100: >> case 0x0127: >> ev_type = HOTKEY; >> - real_ev = sony_nc_hotkeys_decode(event, handle); >> + ret = sony_nc_hotkeys_decode(event, handle); >> >> - if (real_ev > 0) >> - sony_laptop_report_input_event(real_ev); >> - else >> + if (ret > 0) { >> + sony_laptop_report_input_event(ret); >> + real_ev = ret; >> + } else { >> /* restore the original event for reporting */ >> real_ev = event; >> + } > This 4 line else block is superfluous. real_ev is initialized to event and only changed here if ret > 0. Therefore, there is no need to set real_ev to event again. I have simply dropped the else block >