Message ID | 7bd165e82ed3675d4ddee343ab373031e995a126.1686412569.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1635143vqr; Sat, 10 Jun 2023 09:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ToT5xckjWlO13knGucUE/72Atzre5zm0lYxa1KbdyWw2/k358ZA5Cdsv+ihBBq0d4+8Z/ X-Received: by 2002:a05:6a20:728e:b0:10c:3535:162f with SMTP id o14-20020a056a20728e00b0010c3535162fmr6296816pzk.0.1686414844572; Sat, 10 Jun 2023 09:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686414844; cv=none; d=google.com; s=arc-20160816; b=oW/AuNMzrFrTaDFVMm4Hf4dZF6qB/Dudm/FmGuGor5dU/P/2vjvnJ4l5SOYkJXurjz yQOSQX4AU7x0LU/llshQhYetiORIn9SFfAd7VnVHTmlZ60vtUhJbqMQJodxTqyN657xV Qhz/kKeUcs1ZHa8nPnVLpYKSPKStu7IZR1630GCivm8y22mx0AYDoMBMvngOERtI9A2/ 2XfMPxnBfk1MO4gJPcPP2L57wrAdovlUa4mQ28v9CjcjsKzBczmvXDGCEBs2xkOIBmRz wPmxd4CspHIdPw11rH8OIP51kz47u4xF45hOAl89uxInpFC+Krca56dEX/aUXQUNTQri cvxw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x5Q7JFOBqrMC6o8LYzgUOOfoq0P2ZHbeu6tRAx/Ruf8=; b=eIwfXsEu8Ccfje4H4FmPkW8uCdKFq8P7wU20a1VOVzOsuQKe1qbbJTxvBDlXkr6Vgg ugZ2X6V4c7x+QdKpNQtPRY1v3pywbY1+ngPoq0O7JOdFgBnWMG6bJU6xfSJ3qg3mgkxO MCddPHTl/Z5ddbeHU31S+MHbJilvD/0i46S/VNnvxX3nFSqb/fVeA5YF8pMuPi2avWUd to/6Qn+ARMHTxCd59wkXV9fCwhHqsBiw+pCUks7BNlSRie6HzFRQ5aGRUZtnWBHNkQ46 oIPdJEKHZmLUiurjiJe0zFvfVFqqd61azhs9irPs7xds+tcQ3cylknMvubAnvyqTsScp 55mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="YY/e99Cu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k128-20020a633d86000000b005428f77efecsi1745309pga.749.2023.06.10.09.33.51; Sat, 10 Jun 2023 09:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="YY/e99Cu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235799AbjFJP7x (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Sat, 10 Jun 2023 11:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235723AbjFJP7r (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 10 Jun 2023 11:59:47 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3047230D6 for <linux-kernel@vger.kernel.org>; Sat, 10 Jun 2023 08:59:45 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 80zwqFULNV4eY810CqBQ6F; Sat, 10 Jun 2023 17:59:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686412784; bh=x5Q7JFOBqrMC6o8LYzgUOOfoq0P2ZHbeu6tRAx/Ruf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YY/e99CuaAkuIPwh6/SwneGP1bgOzZ4odMId2zpnEkjSh3cZgft7aYxVRg6Wnj3Qr hoAVzpPPXUhZ4doPh2Nf4+hQUrE01Ce/6zSCNAiKs8HMFrxxsP3bZWmqwx9+378vXp fRqwQHcYiJ3v+WlDVbhROmisSkW5xwLzjf5w0F8enIwvJjpm5mvRPzCwUnYZC6pAav FUMjzRH6n00FqPIoVyf67rr1tF0+nIXXxSnP2kCXbLHlUpcBKCl02JWpzHU+EsMhkD jwVgmjma1/1IKVYO1C+ZbRdUX2XhcVVRqisluDxYBfB83SJvP8Atgi95U5FstO/v/5 LYkv4i5LVGZHw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Jun 2023 17:59:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, Alim Akhtar <alim.akhtar@samsung.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, Walter Harms <wharms@bfs.de>, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 3/3] tty: serial: samsung_tty: Use abs() to simplify some code Date: Sat, 10 Jun 2023 17:59:27 +0200 Message-Id: <7bd165e82ed3675d4ddee343ab373031e995a126.1686412569.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: <e4baf6039368f52e5a5453982ddcb9a330fc689e.1686412569.git.christophe.jaillet@wanadoo.fr> References: <e4baf6039368f52e5a5453982ddcb9a330fc689e.1686412569.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768333846203093785?= X-GMAIL-MSGID: =?utf-8?q?1768334131927322772?= |
Series |
[v2,1/3] tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error
|
|
Commit Message
Christophe JAILLET
June 10, 2023, 3:59 p.m. UTC
Use abs() instead of hand-writing it.
Suggested-by: Walter Harms <wharms@bfs.de>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2: new patch
---
drivers/tty/serial/samsung_tty.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On 10. 06. 23, 17:59, Christophe JAILLET wrote: > Use abs() instead of hand-writing it. > > Suggested-by: Walter Harms <wharms@bfs.de> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > v2: new patch > --- > drivers/tty/serial/samsung_tty.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c > index 0b37019820b4..b29e9dfd81a6 100644 > --- a/drivers/tty/serial/samsung_tty.c > +++ b/drivers/tty/serial/samsung_tty.c > @@ -24,6 +24,7 @@ > #include <linux/dmaengine.h> > #include <linux/dma-mapping.h> > #include <linux/slab.h> > +#include <linux/math.h> > #include <linux/module.h> > #include <linux/ioport.h> > #include <linux/io.h> > @@ -1485,9 +1486,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, > } > quot--; > > - calc_deviation = req_baud - baud; > - if (calc_deviation < 0) > - calc_deviation = -calc_deviation; > + calc_deviation = abs(req_baud - baud); Does this work provided req_baud and baud are unsigned? thanks,
On 12. 06. 23, 7:13, Jiri Slaby wrote: > On 10. 06. 23, 17:59, Christophe JAILLET wrote: >> Use abs() instead of hand-writing it. >> >> Suggested-by: Walter Harms <wharms@bfs.de> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> v2: new patch >> --- >> drivers/tty/serial/samsung_tty.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/tty/serial/samsung_tty.c >> b/drivers/tty/serial/samsung_tty.c >> index 0b37019820b4..b29e9dfd81a6 100644 >> --- a/drivers/tty/serial/samsung_tty.c >> +++ b/drivers/tty/serial/samsung_tty.c >> @@ -24,6 +24,7 @@ >> #include <linux/dmaengine.h> >> #include <linux/dma-mapping.h> >> #include <linux/slab.h> >> +#include <linux/math.h> >> #include <linux/module.h> >> #include <linux/ioport.h> >> #include <linux/io.h> >> @@ -1485,9 +1486,7 @@ static unsigned int s3c24xx_serial_getclk(struct >> s3c24xx_uart_port *ourport, >> } >> quot--; >> - calc_deviation = req_baud - baud; >> - if (calc_deviation < 0) >> - calc_deviation = -calc_deviation; >> + calc_deviation = abs(req_baud - baud); > > Does this work provided req_baud and baud are unsigned? Oh, yes, it does, _hopefully_. A bit unexpectedly for me, but: * abs - return absolute value of an argument * @x: the value. If it is unsigned type, it is converted to signed type first. So: Reviewed-by: Jiri Slaby <jirislaby@kernel.org> It would help noting this in the commit log. > thanks,-- js suse labs
diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 0b37019820b4..b29e9dfd81a6 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -24,6 +24,7 @@ #include <linux/dmaengine.h> #include <linux/dma-mapping.h> #include <linux/slab.h> +#include <linux/math.h> #include <linux/module.h> #include <linux/ioport.h> #include <linux/io.h> @@ -1485,9 +1486,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, } quot--; - calc_deviation = req_baud - baud; - if (calc_deviation < 0) - calc_deviation = -calc_deviation; + calc_deviation = abs(req_baud - baud); if (calc_deviation < deviation) { /*