Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2079048pxy; Mon, 2 Aug 2021 18:52:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI7qlDGR5jqeixJDWUFxxPslfhGgE1xJFtBRx67roehHcMb8/G1+d1ZY+zuixVwpUWq9KR X-Received: by 2002:a92:ce4b:: with SMTP id a11mr37147ilr.79.1627955559639; Mon, 02 Aug 2021 18:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627955559; cv=none; d=google.com; s=arc-20160816; b=zJQvrtBm/7kIK/3B28fmWNde0zWwt5dn7ZcmM62l7v8DUFzm5HzmfTFzXBcx8ufeKQ EOy2RxKg24Uqc71b90TfiidxNOGqyBYXtModijseVqjtrRQZ+mIPcwx2Z6/griLRuTbM 4c+8J7duPQUt61VLhrLmKkZ6MMgJPmItzXkWE48xf+ZR5U6nPs9074m5kRxbA1ULU/o6 0lrLOFtz+qZwpr0JZtCLZLE9K0drdZv7moWrV9XkGiTdjWDQEgHd2PPRF5+GjPxvc+GM jQcfnjQVi++9g+rlGxfyKR5mrLyVjlmoayXOjjdhi1DtNGP3i5Px6czfGB00GTnthP/W HETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=YdR8zfCNf4wv+ttRPaVnBXWWBuoumvByTOHRL/URBMA=; b=dIKR743L8e98xBM3NBC164UCHG5zQeT2wy4OIdw9ZcH52kroiVH/5e/p5waaTOtGoK EyzXbROIhWdULGO4JW50hnG0i1VHvieEyGSv4C8ENGUFJ2LDWnjTgBXmVlalLdsE1WUX ZeC7ofaOMihM+ISUVAOpOeBCNWclxh7mwxvpkTLd90cNQ0s9WgpF/juPWj5y91Z6XOVA CAa0hOLvcXuv8IVt6VmlY03I4ucMySQMioXc5TSMSr80B19PYi61PriMCiAciylsZb65 uu9KbR/2mWVzRy+OWm/EOFheOV0oysauF9cMGnREw6f+kUiGruhrDHcNz5AsWK575pr3 JQTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WPMe3vAG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x4si14957107ilj.71.2021.08.02.18.52.27; Mon, 02 Aug 2021 18:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WPMe3vAG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbhHCBui (ORCPT + 99 others); Mon, 2 Aug 2021 21:50:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60604 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233208AbhHCBuh (ORCPT ); Mon, 2 Aug 2021 21:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627955426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YdR8zfCNf4wv+ttRPaVnBXWWBuoumvByTOHRL/URBMA=; b=WPMe3vAGvF/Fmn7PSIAaZzHxyjh0SSggbiZCDn44qrbCVlAnuHyuvWCLrbfPlFkFtIipFx cKhe9kuOqKIDi0EtJYZzjj/hhraPTB20I8bwMlu/C4frht+wjDPgeO0WtjXyIB1JMNQ4XN Cn/KdKCbztsGBUCoqlO2qJM6gJLc+mU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-K9jVr-LgNA6m-JJPto0HLw-1; Mon, 02 Aug 2021 21:50:24 -0400 X-MC-Unique: K9jVr-LgNA6m-JJPto0HLw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94867DF8A3; Tue, 3 Aug 2021 01:50:23 +0000 (UTC) Received: from suzdal.zaitcev.lan (ovpn-112-59.phx2.redhat.com [10.3.112.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3829260BD9; Tue, 3 Aug 2021 01:50:23 +0000 (UTC) Date: Mon, 2 Aug 2021 20:50:22 -0500 From: Pete Zaitcev To: Salah Triki Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, zaitcev@redhat.com Subject: Re: [PATCH] usb: class: usblp: replace conditional statement with min() Message-ID: <20210802205022.357279fc@suzdal.zaitcev.lan> In-Reply-To: <20210803002806.GA1541734@pc> References: <20210803002806.GA1541734@pc> Organization: Red Hat, Inc. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Aug 2021 01:28:06 +0100 Salah Triki wrote: > Replace conditional statement with min() in order to make code cleaner. Issue > found by coccinelle. > +++ b/drivers/usb/class/usblp.c > request, !!dir, recip, value, index, len, retval); > - return retval < 0 ? retval : 0; > + return min(retval, 0); > } I'm very much against this change. The function min() is there for numeric values. But here we have a situation where we do one thing if there was an error, and another thing if there was no error. This sort of abuse is exactly why blindly clicking heels whenever a tool tells you is not optimal. If the objective is to shut the tool up, please consider the following instead: diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 9596e4279294..bbcbcf199fa9 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -264,7 +264,9 @@ static int usblp_ctrl_msg(struct usblp *usblp, int request, int type, int dir, i dev_dbg(&usblp->intf->dev, "usblp_control_msg: rq: 0x%02x dir: %d recip: %d value: %d idx: %d len: %#x result: %d\n", request, !!dir, recip, value, index, len, retval); - return retval < 0 ? retval : 0; + if (retval < 0) + return retval; + return 0; } #define usblp_read_status(usblp, status)\ -- Pete