From: Zbigniew Jędrzejewski-Szmek Date: Fri, 16 May 2025 13:24:12 +0000 (+0200) Subject: basic/terminal-util: simplify output param handling X-Git-Tag: v258-rc1~579^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F37493%2Fhead;p=thirdparty%2Fsystemd.git basic/terminal-util: simplify output param handling Those static functions were written to support optional output params, but they are only ever called with the output param set, and it doesn't make sense to ever call them without the output param. Since those are internal functions, drop this unused complexity. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 7c900c267d4..b8e51e5ea48 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1970,7 +1970,8 @@ static int scan_background_color_response( size_t *ret_processed) { assert(context); - assert(buf || size == 0); + assert(buf); + assert(ret_processed); for (size_t i = 0; i < size; i++) { char c = buf[i]; @@ -2044,9 +2045,7 @@ static int scan_background_color_response( case BACKGROUND_BLUE: if (c == '\x07') { if (context->blue_bits > 0) { - if (ret_processed) - *ret_processed = i + 1; - + *ret_processed = i + 1; return 1; /* success! */ } @@ -2066,9 +2065,7 @@ static int scan_background_color_response( case BACKGROUND_STRING_TERMINATOR: if (c == '\\') { - if (ret_processed) - *ret_processed = i + 1; - + *ret_processed = i + 1; return 1; /* success! */ } @@ -2085,9 +2082,7 @@ static int scan_background_color_response( } } - if (ret_processed) - *ret_processed = size; - + *ret_processed = size; return 0; /* all good, but not enough data yet */ } @@ -2214,7 +2209,8 @@ static int scan_cursor_position_response( size_t *ret_processed) { assert(context); - assert(buf || size == 0); + assert(buf); + assert(ret_processed); for (size_t i = 0; i < size; i++) { char c = buf[i]; @@ -2247,9 +2243,7 @@ static int scan_cursor_position_response( case CURSOR_COLUMN: if (c == 'R') { if (context->column > 0) { - if (ret_processed) - *ret_processed = i + 1; - + *ret_processed = i + 1; return 1; /* success! */ } @@ -2272,9 +2266,7 @@ static int scan_cursor_position_response( context->row = context->column = 0; } - if (ret_processed) - *ret_processed = size; - + *ret_processed = size; return 0; /* all good, but not enough data yet */ }