Skip to content

Commit 07776e1

Browse files
authored
Merge pull request #5751 from btriller/fix-log
libenv/sysinfo: Fix detected os description
2 parents 15852df + 1017d44 commit 07776e1

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

libenv/sysinfo.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,15 @@ static void GetNameInfo3(EvalContext *ctx)
549549
bool found = false;
550550
for (i = 0; !found && (i < PLATFORM_CONTEXT_MAX); i++)
551551
{
552-
char sysname[CF_BUFSIZE];
553-
strlcpy(sysname, VSYSNAME.sysname, CF_BUFSIZE);
554-
ToLowerStrInplace(sysname);
555-
552+
#ifndef NDEBUG
553+
for (const char *ch = VSYSNAME.sysname; *ch != '\0'; ch++)
554+
{
555+
assert(islower(*ch));
556+
}
557+
#endif /* NDEBUG */
556558
/* FIXME: review those strcmps. Moved out from StringMatch */
557-
if (!strcmp(CLASSATTRIBUTES[i][0], sysname)
558-
|| StringMatchFull(CLASSATTRIBUTES[i][0], sysname))
559+
if (!strcmp(CLASSATTRIBUTES[i][0], VSYSNAME.sysname)
560+
|| StringMatchFull(CLASSATTRIBUTES[i][0], VSYSNAME.sysname))
559561
{
560562
if (!strcmp(CLASSATTRIBUTES[i][1], VSYSNAME.machine)
561563
|| StringMatchFull(CLASSATTRIBUTES[i][1], VSYSNAME.machine))
@@ -580,16 +582,10 @@ static void GetNameInfo3(EvalContext *ctx)
580582
}
581583
}
582584

583-
if (!found)
584-
{
585-
i = 0;
586-
}
587-
588585
Log(LOG_LEVEL_VERBOSE, "%s - ready", NameVersion());
589586
Banner("Environment discovery");
590587

591-
snprintf(workbuf, CF_BUFSIZE, "%s", CLASSTEXT[i]); // See: cppcheck_suppressions.txt
592-
588+
snprintf(workbuf, CF_BUFSIZE, "%s", CLASSTEXT[VSYSTEMHARDCLASS]);
593589

594590
Log(LOG_LEVEL_VERBOSE, "Host name is: %s", VSYSNAME.nodename);
595591
Log(LOG_LEVEL_VERBOSE, "Operating System Type is %s", VSYSNAME.sysname);

tests/static-check/cppcheck_suppressions.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// suppress warnings for access to individual bytes of a uint32 in platform.h
22
objectIndex:libntech/libutils/platform.h
33

4-
// cppcheck is not clever enough to see that if (i >= PLATFORM_CONTEXT_MAX) then 'found' is false
5-
arrayIndexOutOfBounds:libenv/sysinfo.c:587
6-
74
// 'psin' is assigned to 'ai->ai_addr' and 'ai' is returned to the caller
85
memleak:libntech/libcompat/getaddrinfo.c:153
96

0 commit comments

Comments
 (0)