From: Alexandru Ardelean <alexandru.ardelean-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
To: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-ide-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
Alexandru Ardelean
<alexandru.ardelean-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 01/16] lib: fix match_string() helper on -1 array size
Date: Wed, 8 May 2019 14:28:26 +0300 [thread overview]
Message-ID: <20190508112842.11654-2-alexandru.ardelean@analog.com> (raw)
In-Reply-To: <20190508112842.11654-1-alexandru.ardelean-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
The documentation the `_match_string()` helper mentions that `n`
should be:
* @n: number of strings in the array or -1 for NULL terminated arrays
The behavior of the function is different, in the sense that it exits on
the first NULL element in the array, regardless of whether `n` is -1 or a
positive number.
This patch changes the behavior, to exit the loop when a NULL element is
found and n == -1. Essentially, this aligns the behavior with the
doc-string.
There are currently many users of `match_string()`, and so, in order to go
through them, the next patches in the series will focus on doing some
cosmetic changes, which are aimed at grouping the users of
`match_string()`.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
lib/string.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/string.c b/lib/string.c
index 3ab861c1a857..76edb7bf76cb 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -648,8 +648,11 @@ int match_string(const char * const *array, size_t n, const char *string)
for (index = 0; index < n; index++) {
item = array[index];
- if (!item)
+ if (!item) {
+ if (n != (size_t)-1)
+ continue;
break;
+ }
if (!strcmp(item, string))
return index;
}
--
2.17.1
next prev parent reply other threads:[~2019-05-08 11:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 11:28 [PATCH 00/16] treewide: fix match_string() helper when array size Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 01/16] lib: fix match_string() helper when array size is positive Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 02/16] treewide: rename match_string() -> __match_string() Alexandru Ardelean
[not found] ` <20190508112842.11654-1-alexandru.ardelean-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
2019-05-08 11:28 ` Alexandru Ardelean [this message]
2019-05-08 11:31 ` [PATCH 01/16] lib: fix match_string() helper on -1 array size Ardelean, Alexandru
2019-05-08 11:28 ` [PATCH 03/16] lib,treewide: add new match_string() helper/macro Alexandru Ardelean
2019-05-08 13:11 ` Andy Shevchenko
2019-05-08 13:18 ` [PATCH 03/16] lib, treewide: " Greg KH
2019-05-08 13:22 ` [PATCH 03/16] lib,treewide: " Ardelean, Alexandru
2019-05-10 9:15 ` Ardelean, Alexandru
2019-05-10 14:34 ` [PATCH 03/16] lib, treewide: " andriy.shevchenko
2019-05-13 7:00 ` [PATCH 03/16] lib,treewide: " Ardelean, Alexandru
2019-05-08 11:28 ` [PATCH 16/16] sched: debug: use " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 04/16] powerpc/xmon: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 05/16] ALSA: oxygen: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 06/16] x86/mtrr: use new match_string() helper + add gaps == minor fix Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 07/16] device connection: use new match_string() helper/macro Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 08/16] cpufreq/intel_pstate: remove NULL entry + use match_string() Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 09/16] mmc: sdhci-xenon: use new match_string() helper/macro Alexandru Ardelean
2019-05-08 12:20 ` Dan Carpenter
2019-05-08 13:26 ` Ardelean, Alexandru
2019-05-10 9:13 ` Ardelean, Alexandru
2019-05-10 11:01 ` Dan Carpenter
2019-05-10 11:04 ` Ardelean, Alexandru
2019-05-08 11:28 ` [PATCH 10/16] pinctrl: armada-37xx: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 11/16] mm/vmpressure.c: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 12/16] rdmacg: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 13/16] drm/edid: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 14/16] staging: gdm724x: " Alexandru Ardelean
2019-05-08 11:28 ` [PATCH 15/16] video: fbdev: pxafb: " Alexandru Ardelean
2019-05-28 7:39 ` [PATCH 1/3][V2] lib: fix match_string() helper on -1 array size Alexandru Ardelean
2019-05-28 7:39 ` [PATCH 2/3][V2] treewide: rename match_string() -> __match_string() Alexandru Ardelean
2019-05-28 7:39 ` [PATCH 3/3][V2] lib: re-introduce new match_string() helper/macro Alexandru Ardelean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190508112842.11654-2-alexandru.ardelean@analog.com \
--to=alexandru.ardelean-oylxuock7orqt0dzr+alfa@public.gmane.org \
--cc=andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-ide-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).