[LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
Po-Hsu Lin
po-hsu.lin@canonical.com
Tue Aug 18 18:20:08 CEST 2020
On Tue, Aug 18, 2020 at 11:29 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > static char *parse_digit(const char *str, int *d)
> > {
> > unsigned long v;
> > @@ -127,6 +130,8 @@ int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
> >
> > const char *tst_kvcmp_distname(const char *kver)
> > {
> > + static char distname[64];
> > + char *tok;
> > if (strstr(kver, ".el5uek"))
> > return "OL5UEK";
> >
> > @@ -139,6 +144,17 @@ const char *tst_kvcmp_distname(const char *kver)
> > if (strstr(kver, ".el6"))
> > return "RHEL6";
> >
> > + // Special case for other releases with the presencse of /etc/os-release
> > + if (access(OSRELEASE_PATH, F_OK) != -1) {
> > + SAFE_FILE_LINES_SCANF(NULL, OSRELEASE_PATH, "ID=%s", distname);
> > + tok = strtok(distname,"\0");
>
> Isn't this strtok() useless?
Hello,
oh indeed, the delimiter in strtok will become null character anyway.
I think just tok = distname can do the trick here.
I will send v3 tomorrow.
Thank you
>
>
> Other than that the patchset looks fine.
>
> > + while (*tok) {
> > + *tok = toupper((unsigned char) *tok);
> > + tok++;
> > + }
> > + return distname;
> > + }
> > +
> > return NULL;
> > }
> >
> > --
> > 2.25.1
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
More information about the ltp
mailing list