cgroup: Fix build with -Werror=return-type
PATCH 1/2 cgroup: Fix build with -Werror=return-type
From: Petr Vorel <[email protected]>
Adding bogus return to keep compiler happy.
---
Hi,
IMHO using pragma would be better, but I don't know how to write it portable way.
Kind regards,
Petr
lib/tst_cgroup.c | 1 + 1 file changed, 1 insertion(+)
lib/tst_cgroup.c +1 -0
@@ -49,6 +49,7 @@ enum tst_cgroup_ver tst_cgroup_version(void)return TST_CGROUP_V1 ;tst_brk (TCONF ,"Cgroup is not configured" ); +return TST_CGROUP_V1 ;/* fix -Werror=return-type */ } static void tst_cgroup1_mount(const char *name, const char *option,
Signature · 1 line
2.27.0
PATCH 2/2 travis: Add -Werror=return-type
From: Petr Vorel <[email protected]>
--- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
build.sh +1 -1
@@ -9,7 +9,7 @@ set -e -CFLAGS="${CFLAGS:--Wformat -Werror=format-security -Werror=implicit-function-declaration -fno-common}" +CFLAGS="${CFLAGS:--Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=return-type -fno-common}" CC="${CC:-gcc}" DEFAULT_PREFIX="$HOME/ltp-install"
Signature · 1 line
2.27.0
PATCH 1/2 cgroup: Fix build with -Werror=return-type
In reply to Petr VorelQuoted 24 lines · Petr Vorel
From: Petr Vorel <[email protected]>
Adding bogus return to keep compiler happy.
Fixes 3b716981b ("lib: add new cgroup test API")Signed-off-by Petr Vorel <[email protected]>---
Hi,IMHO using pragma would be better, but I don't know how to write it portable way.
Kind regards,
Petrlib/tst_cgroup.c | 1 + 1 file changed, 1 insertion(+)lib/tst_cgroup.c +0
-0
lib/tst_cgroup.c enum tst_cgroup_ver tst_cgroup_version(void) · line 53
Quoted 5 lines
lib/tst_cgroup.c +1
-0@@ -49,6 +49,7 @@ enum tst_cgroup_ver tst_cgroup_version(void)return TST_CGROUP_V1 ;tst_brk (TCONF ,"Cgroup is not configured" ); +return TST_CGROUP_V1 ;/* fix -Werror=return-type */
This return looks strange since it will never go to here.
How about this?
enum tst_cgroup_ver tst_cgroup_version(void)
{
enum tst_cgroup_ver cg_ver;
if (tst_cgroup_check("cgroup2")) {
if (!tst_is_mounted("cgroup2") && tst_is_mounted("cgroup"))
cg_ver = TST_CGROUP_V1;
else
cg_ver = TST_CGROUP_V2;
goto out;
}
if (tst_cgroup_check("cgroup"))
cg_ver = TST_CGROUP_V1;
if (!tg_ver)
tst_brk(TCONF, "Cgroup is not configured");out:
return cg_ver; }
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200622/445db0f7/attachment.htm>
PATCH 1/2 cgroup: Fix build with -Werror=return-type
Hi Li,
Quoted 7 lines
Quoted 2 lines
tst_brk(TCONF, "Cgroup is not configured");+ return
TST_CGROUP_V1; /* fix -Werror=return-type */This return looks strange since it will never go to here.
How about this?
I'm sorry, I overlooked your mail and push whole patchset.
LGTM, feel free to merge.
Quoted 17 lines
enum
tst_cgroup_vertst_cgroup_version(void){ enum tst_cgroup_ver cg_ver; if (tst_cgroup_check("cgroup2")) { if (!tst_is_mounted("cgroup2") && tst_is_mounted("cgroup")) cg_ver = TST_CGROUP_V1; else cg_ver = TST_CGROUP_V2; goto out; } if (tst_cgroup_check("cgroup")) cg_ver = TST_CGROUP_V1; if (!tg_ver)
Typo:
if (!cg_ver)
Quoted 5 lines
tst_brk(TCONF, "Cgroup is not configured");out:
return cg_ver; }
Kind regards,
Petr
PATCH 1/2 cgroup: Fix build with -Werror=return-type
Quoted 6 lines · Petr Vorel
Hi Li,
Quoted 2 lines
Quoted 2 lines
tst_brk(TCONF, "Cgroup is not configured");+ return
TST_CGROUP_V1; /* fix -Werror=return-type */
Quoted 6 lines
Quoted 3 lines
This return looks strange since it will never go to here.
How about this?
I'm sorry, I overlooked your mail and push whole patchset.
Never mind:).
I resend a patch v2 to cover more situations, that would be great if you can help review/test again.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200622/35823e55/attachment.htm>
PATCH 1/2 cgroup: Fix build with -Werror=return-type
In reply to Petr VorelQuoted 6 lines · Petr Vorel
Hi Li,
Quoted 2 lines
Quoted 2 lines
tst_brk(TCONF, "Cgroup is not configured");+ return
TST_CGROUP_V1; /* fix -Werror=return-type */
Quoted 9 lines
Quoted 3 lines
This return looks strange since it will never go to here.
How about this?
I'm sorry, I overlooked your mail and push whole patchset.
LGTM, feel free to merge.
Tested-by Petr Vorel <[email protected]>
This is correct, I go back to this v1 way and pushed. Thanks Petr!
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200622/7d1196ab/attachment-0001.htm>