From 1fd08835335e5f8f28b17668e4ce0d10277f9113 Mon Sep 17 00:00:00 2001 From: Remco van Engelen Date: Tue, 27 Feb 2024 22:36:48 +0100 Subject: [PATCH] Fix build issue (ignore unused result) --- cgroups.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cgroups.c b/cgroups.c index 3a753ba..92cb387 100644 --- a/cgroups.c +++ b/cgroups.c @@ -376,7 +376,10 @@ walkcgroup(char *dirname, struct cgchainer *cparent, int parentseq, closedir(dirp); - chdir(".."); + // return to original directory + // + if ( chdir("..") == -1) + return -1; ccp->cstat->gen.procsbelow = procsbelow; @@ -671,15 +674,16 @@ gettotpressure(char *fname) if ( (fp = fopen(fname, "r")) != NULL) { - fgets(linebuf, sizeof(linebuf), fp); // skip 'some' line - - // only handle second line: 'total' pressure - // - if ( fgets(linebuf, sizeof(linebuf), fp) != NULL) + if ( fgets(linebuf, sizeof(linebuf), fp) != NULL) // skip 'some' line { - sscanf(linebuf, psiformat, - &psitype, &a10, &a60, &a300, &totpressure); - } + // only handle second line: 'total' pressure + // + if ( fgets(linebuf, sizeof(linebuf), fp) != NULL) + { + sscanf(linebuf, psiformat, + &psitype, &a10, &a60, &a300, &totpressure); + } + } fclose(fp); }