From 0cbf135293b07f821ff427de62e01e6f113bde98 Mon Sep 17 00:00:00 2001 From: rilysh Date: Mon, 29 Jan 2024 23:16:13 +0530 Subject: [PATCH] libnvpair.c: replace strstr() with strchr() for a single character Since we're looking for a single new-line character in the haystack, it's better (and slightly more efficient) to use strchr() instead of strstr(). Reviewed-by: Brian Behlendorf Reviewed-by: Richard Yao Signed-off-by: rilysh Closes #15798 --- lib/libnvpair/libnvpair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libnvpair/libnvpair.c b/lib/libnvpair/libnvpair.c index f19ee707a5..7141c437b8 100644 --- a/lib/libnvpair/libnvpair.c +++ b/lib/libnvpair/libnvpair.c @@ -383,7 +383,7 @@ nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, pctl->nvprt_btwnarrfmt_nl = 0; } else { pctl->nvprt_btwnarrfmt = fmt; - pctl->nvprt_btwnarrfmt_nl = (strstr(fmt, "\n") != NULL); + pctl->nvprt_btwnarrfmt_nl = (strchr(fmt, '\n') != NULL); } break;