]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslocks: (refactor) use global bytes in get_json_type_for_column()
authorMasatake YAMATO <yamato@redhat.com>
Mon, 15 Dec 2025 20:15:30 +0000 (05:15 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 29 Dec 2025 07:35:45 +0000 (16:35 +0900)
`get_json_type_for_column()` used to take `representing_in_bytes`, but
every caller passed the global `bytes`. The parameter added no value
and split the ownership of the setting. Drop the parameter and read
the global `bytes` instead.

This aligns lslocks with lsblk and prepares for adding `-Q/--filter`.
lsblk also reads global `bytes` defined in lsblk.c

No functional change intended.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lslocks.c

index bfdd3f160532bbeee565ed09c649a46a35d84078..f8d029d1e5ab82aa2f4384620e18ef1f238bbab0 100644 (file)
@@ -721,11 +721,11 @@ static void rem_tnode(void *node)
        free(node);
 }
 
-static int get_json_type_for_column(int column_id, int representing_in_bytes)
+static int get_json_type_for_column(int column_id)
 {
        switch (column_id) {
        case COL_SIZE:
-               if (!representing_in_bytes)
+               if (!bytes)
                        return SCOLS_JSON_STRING;
                FALLTHROUGH;
        case COL_PID:
@@ -776,7 +776,7 @@ static struct libscols_table *init_scols_table(void)
 
                if (json) {
                        int id = get_column_id(i);
-                       int json_type = get_json_type_for_column(id, bytes);
+                       int json_type = get_json_type_for_column(id);
                        scols_column_set_json_type(cl, json_type);
                }
 
@@ -841,7 +841,7 @@ static void __attribute__((__noreturn__)) list_columns(void)
 
        for (size_t i = 0; i < ARRAY_SIZE(infos); i++) {
                if (i != COL_SIZE) {
-                       int json_type = get_json_type_for_column(i, bytes);
+                       int json_type = get_json_type_for_column(i);
                        xcolumn_list_table_append_line(col_tb, infos[i].name,
                                                       json_type, NULL,
                                                       _(infos[i].help));