LU-17501 libcfs: fix ncpt check for cpt patterns
Coverty Scan found the following:
*** CID 454272: Control flow issues (DEADCODE)
/lnet/lnet/lib-cpt.c: 1114 in cfs_cpt_table_create_pattern()
1108 } else if (!ncpt) { /* scan for bracket at start of
partition */
1109 bracket = str;
1110 while ((bracket = strchr(bracket, '['))) {
1111 bracket++;
1112 ncpt++;
1113 }
CID 454272: Control flow issues (DEADCODE)
Execution cannot reach the expression "ncpt > num_node_state(N
_ONLINE)" inside this statement: "if ((!ncpt && !exclude) || ...".
1114 if ((!ncpt && !exclude) ||
1115 (node && ncpt > num_online_nodes()) ||
1116 (!node && ncpt > num_online_cpus())) {
1117 CERROR("Invalid pattern '%s', or too many
partitions %dn",
1118 pattern_dup, ncpt);
1119 rc = -EINVAL;
The issue was that these checks were inside of the "else if (!ncpt)"
conditional block when they should have been outside.
CoverityID: 454272 ("Control flow issues")
Fixes:
111f5836ec ("LU-17501 libcfs: allow CPT exclude list for cores")
Signed-off-by: Frederick Dilger <fdilger@whamcloud.com>
Change-Id: I4befcbdc5d8e63a3783ba09416a61a7c80135635
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57659
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>