]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: simplify SOURCES code
authorKarel Zak <kzak@redhat.com>
Mon, 22 Apr 2024 09:51:56 +0000 (11:51 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Apr 2024 10:01:33 +0000 (12:01 +0200)
This complicated implementation originated from an early version of
zero-separated items for libsmartcols. It is no longer necessary.

References: https://github.com/util-linux/util-linux/pull/2983
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/column.c
misc-utils/lsblk.c

index 5700bac3b91a0e5631570bca3b5fcb04d427a256..586a485abeffbb93b1f6f6f91e715f4a6292f48d 100644 (file)
@@ -470,7 +470,7 @@ char *scols_wrapnl_nextchunk(const struct libscols_column *cl __attribute__((unu
  * This is built-in function for scols_column_set_wrapfunc(). This function
  * walk string separated by \0.
  *
- * For example for data "AAA\0BBB\0CCC" the next chunk is "BBB".
+ * For example for data "AAA\0BBB\0CCC\0" the next chunk is "BBB".
  *
  * Returns: next chunk
  *
index fbc0356451b62bb6927d47cfce4f14b08ff51eac..2df7752670744e9676d8b5106f5e6f25c0d2ba65 100644 (file)
@@ -935,8 +935,7 @@ static char *device_get_data(
                                ul_buffer_append_string(&buf, "[SWAP]");
                        else
                                ul_buffer_append_string(&buf, mnt_fs_get_target(fs));
-                       if (i + 1 < n)
-                               ul_buffer_append_data(&buf, "\0", 1);
+                       ul_buffer_append_data(&buf, "\0", 1);
                }
                str = ul_buffer_get_data(&buf, datasiz, NULL);
                break;
@@ -953,8 +952,7 @@ static char *device_get_data(
                        if (mnt_fs_is_swaparea(fs))
                                continue;
                        ul_buffer_append_string(&buf, root ? root : "/");
-                       if (i + 1 < n)
-                               ul_buffer_append_data(&buf, "\0", 1);
+                       ul_buffer_append_data(&buf, "\0", 1);
                }
                str = ul_buffer_get_data(&buf, datasiz, NULL);
                break;
@@ -1276,7 +1274,7 @@ static void device_fill_scols_cell(struct lsblk_device *dev,
        ce = scols_line_get_cell(ln, colnum);
        if (!ce)
                return;
-       rc = datasiz ? scols_cell_refer_memory(ce, data, datasiz + 1)
+       rc = datasiz ? scols_cell_refer_memory(ce, data, datasiz)
                     : scols_cell_refer_data(ce, data);
        if (rc)
                err(EXIT_FAILURE, _("failed to add output data"));