]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/terminal-util: simplify output param handling 37493/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 May 2025 13:24:12 +0000 (15:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 May 2025 13:33:50 +0000 (15:33 +0200)
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.

src/basic/terminal-util.c

index 7c900c267d4a721ec5f26dd5ea6e97f44561dd5c..b8e51e5ea48ab6c81e0619367c45c54412cf1468 100644 (file)
@@ -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 */
 }