From 4f807791eee8ead3f38f1dce76f748fa0773f9a6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 18 May 2019 22:09:25 +0100 Subject: lib/mangle: fix possible null pointer dereference [cppcheck] Fix effects code that is used when testing util-linux, so quite low impact. Signed-off-by: Sami Kerola --- lib/mangle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mangle.c b/lib/mangle.c index b514cd8d3..87802fbda 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -155,9 +155,9 @@ int main(int argc, char *argv[]) } x = strdup(argv[2]); - unmangle_to_buffer(x, x, strlen(x) + 1); - if (x) { + unmangle_to_buffer(x, x, strlen(x) + 1); + printf("self-unmangled: '%s'\n", x); free(x); } -- cgit v1.2.3-55-g7522 From cc7ffe129d7c01eb3d4bf650e70b6befef6e1e19 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 18 May 2019 22:56:15 +0100 Subject: lib/colors: remove redundant if statement Signed-off-by: Sami Kerola --- lib/colors.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/colors.c b/lib/colors.c index ecec0ac30..26f3c81f7 100644 --- a/lib/colors.c +++ b/lib/colors.c @@ -662,11 +662,9 @@ static int colors_terminal_is_ready(void) if (setupterm(NULL, STDOUT_FILENO, &ret) != 0 || ret != 1) goto none; ncolors = tigetnum("colors"); - if (ncolors <= 2) - goto none; } #endif - if (ncolors != -1) { + if (1 < ncolors) { DBG(CONF, ul_debug("terminal is ready (supports %d colors)", ncolors)); return 1; } -- cgit v1.2.3-55-g7522