Skip to content

Commit

Permalink
libnvpair.c: replace strstr() with strchr() for a single character
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Richard Yao <[email protected]>
Signed-off-by: rilysh <[email protected]>
Closes openzfs#15798
  • Loading branch information
rilysh authored and lundman committed Mar 13, 2024
1 parent 2097906 commit da9600f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libnvpair/libnvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit da9600f

Please sign in to comment.