On Thu, Apr 24, 2025 at 07:02:18PM +0530, Anup Patel wrote: > On Sat, Apr 12, 2025 at 7:15 PM Andrew Jones <ajones@xxxxxxxxxxxxxxxx> wrote: > > > bool riscv__isa_extension_disabled(struct kvm *kvm, unsigned long isa_ext_id) > > > { > > > struct isa_ext_info *info = NULL; > > > @@ -128,16 +142,39 @@ bool riscv__isa_extension_disabled(struct kvm *kvm, unsigned long isa_ext_id) > > > int riscv__cpu_type_parser(const struct option *opt, const char *arg, int unset) > > > { > > > struct kvm *kvm = opt->ptr; > > > + const char *str, *nstr; > > > + int len; > > > > > > - if ((strncmp(arg, "min", 3) && strncmp(arg, "max", 3)) || strlen(arg) != 3) > > > + if ((strncmp(arg, "min", 3) || strlen(arg) < 3) && > > > > If arg == 'min', then it can't be less than 3 so the '|| strlen(arg) < 3' > > is dead code. > > > > > + (strncmp(arg, "max", 3) || strlen(arg) != 3)) > > > > I think we want > > > > if (strlen(arg) < 3 || > > (strlen(arg) == 3 && strcmp(arg, "min") && strcmp(arg, "max")) || > > strncmp(arg, "min", 3)) > > Nope, for cpu-type = "min" the strlen(arg) can be greater than 3 > because of comma separated extensions provided as part of > cpu-type value. That's what the last condition 'strncmp(arg, "min", 3)' of my proposed compound-condition is confirming. That condition is only checked for strlen(arg) > 3. Thanks, drew