From patchwork Sun Mar 31 18:52:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Abramov X-Patchwork-Id: 1071942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=yandex.ru Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O/3HDHj2"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yandex.ru header.i=@yandex.ru header.b="m1ZKNlBm"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44XPkD5BSlz9sPn for ; Mon, 1 Apr 2019 05:53:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:MIME-Version:Subject: References:In-Reply-To:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KOVhmeNgBhW1M2ZQph16InDcLvRG4YwANeitP5776gE=; b=O/3HDHj2aEcrOQ 9tSGBaRGZBiP270QFIYgEG9M3dtZhNPm8kyWOJyeKfkyvO2X1uRW7+TAMjQhKn6JetlYUCr+ekEd8 +fkB1L6Y6C2yUrEh6uYSKaGog/nFpVhi2LkqOKzLcLJ9eVfgF4/JrmzN7o/jvxDdm1v8VswjBzaK+ BMKM8Qh6/bMr5Ka/b7Ksj5zb+n2ClMz9FQ1UIsV8O6ny82VjaP+6wMn/btdL6ORA+2oJCrRUUZa6w F8FWXSOsj2mFINQZEOa9kGJRAeUzO6TtB6NI2legHQSEc/bFAHS/WbG/+B04ijsc4GRVFdRGPuaPm 3rXBtjAnMthc0S4FXL/A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hAfZq-0006GJ-H6; Sun, 31 Mar 2019 18:53:06 +0000 Received: from forward501p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:120]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hAfZh-00067s-Lb; Sun, 31 Mar 2019 18:52:59 +0000 Received: from mxback23g.mail.yandex.net (mxback23g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:323]) by forward501p.mail.yandex.net (Yandex) with ESMTP id B8DD13500132; Sun, 31 Mar 2019 21:52:54 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback23g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BbpgY54qw3-qosKPq2X; Sun, 31 Mar 2019 21:52:53 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1554058373; bh=BQnnxR4kw87jVTS35+ERA5CJJaS0IljnV5U8+ck2PQU=; h=Message-Id:Cc:Subject:In-Reply-To:Date:References:To:From; b=m1ZKNlBmFV8ctF8j6bjoTFrFSn0UtgikD63it6jMejB19orfSdk915I7IaNeF4LjC xaXVECjsM2dfwW+2iqxz4lAWIng+1r0dEq5q19VGfniLoEs6cgD55YqbeX2EwI3IXw gY2Y1px8cetyVCIQk2WAOXEhrYAMvQNd/kfL4aTY= Authentication-Results: mxback23g.mail.yandex.net; dkim=pass header.i=@yandex.ru Received: by iva6-3ac3de5fcc31.qloud-c.yandex.net with HTTP; Sun, 31 Mar 2019 21:52:50 +0300 From: Andrey Abramov To: vgupta , benh , paulus , mpe , tglx , mingo , bp , hpa , x86 , mark , jlbec , richard , dedekind1 , adrian.hunter , gregkh , naveen.n.rao , jpoimboe , Dave Chinner , darrick.wong , ard.biesheuvel , George Spelvin , linux-snps-arc , Linux Kernel Mailing List , linuxppc-dev , ocfs2-devel , linux-mtd , sfr In-Reply-To: <19606671554056883@myt3-1179f584969c.qloud-c.yandex.net> References: <19606671554056883@myt3-1179f584969c.qloud-c.yandex.net> Subject: [PATCH v2 5/5] Lib: sort.h: replace int size with size_t size in the swap function MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 31 Mar 2019 21:52:50 +0300 Message-Id: <23051461554058370@iva6-3ac3de5fcc31.qloud-c.yandex.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190331_115258_066100_86B27A5B X-CRM114-Status: UNSURE ( 9.03 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [2a02:6b8:0:1472:2741:0:8b7:120 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (st5pub[at]yandex.ru) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jannh , peterz , Rasmus Villemoes , "yamada.masahiro" , Morton Andrew , Andy Shevchenko , jslaby Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Replace int type with size_t type of the size argument in the swap function, also affect all its dependencies. It's always been weird that sort() takes a size_t element size, but passes an int size to (*swap)(). Not a bug because we don't sort objects >2GB large, but it's ugly. Signed-off-by: Andrey Abramov Reviewed by: George Spelvin --- arch/x86/kernel/unwind_orc.c | 2 +- include/linux/sort.h | 2 +- kernel/jump_label.c | 2 +- lib/extable.c | 2 +- lib/sort.c | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index 89be1be1790c..1078c287198c 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -176,7 +176,7 @@ static struct orc_entry *orc_find(unsigned long ip) return orc_ftrace_find(ip); } -static void orc_sort_swap(void *_a, void *_b, int size) +static void orc_sort_swap(void *_a, void *_b, size_t size) { struct orc_entry *orc_a, *orc_b; struct orc_entry orc_tmp; diff --git a/include/linux/sort.h b/include/linux/sort.h index 2b99a5dd073d..aea39d552ff7 100644 --- a/include/linux/sort.h +++ b/include/linux/sort.h @@ -6,6 +6,6 @@ void sort(void *base, size_t num, size_t size, int (*cmp)(const void *, const void *), - void (*swap)(void *, void *, int)); + void (*swap)(void *, void *, size_t)); #endif diff --git a/kernel/jump_label.c b/kernel/jump_label.c index bad96b476eb6..340b788571fb 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -45,7 +45,7 @@ static int jump_label_cmp(const void *a, const void *b) return 0; } -static void jump_label_swap(void *a, void *b, int size) +static void jump_label_swap(void *a, void *b, size_t size) { long delta = (unsigned long)a - (unsigned long)b; struct jump_entry *jea = a; diff --git a/lib/extable.c b/lib/extable.c index f54996fdd0b8..db2888342cd7 100644 --- a/lib/extable.c +++ b/lib/extable.c @@ -28,7 +28,7 @@ static inline unsigned long ex_to_insn(const struct exception_table_entry *x) #ifndef ARCH_HAS_RELATIVE_EXTABLE #define swap_ex NULL #else -static void swap_ex(void *a, void *b, int size) +static void swap_ex(void *a, void *b, size_t size) { struct exception_table_entry *x = a, *y = b, tmp; int delta = b - a; diff --git a/lib/sort.c b/lib/sort.c index 50855ea8c262..60fbbc29104a 100644 --- a/lib/sort.c +++ b/lib/sort.c @@ -114,7 +114,7 @@ static void swap_bytes(void *a, void *b, size_t n) } while (n); } -typedef void (*swap_func_t)(void *a, void *b, int size); +typedef void (*swap_func_t)(void *a, void *b, size_t size); /* * The values are arbitrary as long as they can't be confused with @@ -138,7 +138,7 @@ static void do_swap(void *a, void *b, size_t size, swap_func_t swap_func) else if (swap_func == SWAP_BYTES) swap_bytes(a, b, size); else - swap_func(a, b, (int)size); + swap_func(a, b, size); } /** @@ -187,7 +187,7 @@ static size_t parent(size_t i, unsigned int lsbit, size_t size) */ void sort(void *base, size_t num, size_t size, int (*cmp_func)(const void *, const void *), - void (*swap_func)(void *, void *, int size)) + void (*swap_func)(void *, void *, size_t size)) { /* pre-scale counters for performance */ size_t n = num * size, a = (num/2) * size;