Message ID | 20211210083545.10649-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | Lua: fix getroot function's type detection | expand |
Hi Christian, On 10.12.21 09:35, Christian Storm wrote: > strncmp() returns 0 on match, hence it needs > to read !strncmp(...). > One more time I did the same mistake.... Thanks for fixing, I apply to -master ! > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/lua_interface.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c > index e42eac4..1cc0d9d 100644 > --- a/corelib/lua_interface.c > +++ b/corelib/lua_interface.c > @@ -820,9 +820,9 @@ static int l_getroot(lua_State *L) { > if (count_string_array((const char **)root) > 1) { > if (!strncmp(root[0], "UUID", strlen("UUID"))) { > type = ROOT_DEV_UUID; > - } else if (strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { > + } else if (!strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { > type = ROOT_DEV_PARTUUID; > - } else if (strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { > + } else if (!strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { > type = ROOT_DEV_PARTLABEL; > } > value = root[1]; > Best regards, Stefano
Hi Stefano, > > On 10.12.21 09:35, Christian Storm wrote: > > strncmp() returns 0 on match, hence it needs > > to read !strncmp(...). > > > > One more time I did the same mistake.... > > Thanks for fixing, I apply to -master ! Thanks! Admittedly, this is really counter-intuitive and I only found it while casual-friday working on the other getroot() patches... > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > > --- > > corelib/lua_interface.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c > > index e42eac4..1cc0d9d 100644 > > --- a/corelib/lua_interface.c > > +++ b/corelib/lua_interface.c > > @@ -820,9 +820,9 @@ static int l_getroot(lua_State *L) { > > if (count_string_array((const char **)root) > 1) { > > if (!strncmp(root[0], "UUID", strlen("UUID"))) { > > type = ROOT_DEV_UUID; > > - } else if (strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { > > + } else if (!strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { > > type = ROOT_DEV_PARTUUID; > > - } else if (strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { > > + } else if (!strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { > > type = ROOT_DEV_PARTLABEL; > > } > > value = root[1]; > > Kind regards, Christian
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index e42eac4..1cc0d9d 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -820,9 +820,9 @@ static int l_getroot(lua_State *L) { if (count_string_array((const char **)root) > 1) { if (!strncmp(root[0], "UUID", strlen("UUID"))) { type = ROOT_DEV_UUID; - } else if (strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { + } else if (!strncmp(root[0], "PARTUUID", strlen("PARTUUID"))) { type = ROOT_DEV_PARTUUID; - } else if (strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { + } else if (!strncmp(root[0], "PARTLABEL", strlen("PARTLABEL"))) { type = ROOT_DEV_PARTLABEL; } value = root[1];
strncmp() returns 0 on match, hence it needs to read !strncmp(...). Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/lua_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)