]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: don't directly access struct members
authorKarel Zak <kzak@redhat.com>
Fri, 27 Oct 2023 09:42:15 +0000 (11:42 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 Nov 2023 21:25:47 +0000 (22:25 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/column.c
libsmartcols/src/filter-param.c

index bf3b1a2d0dfec1c8499174bce4e8fd07319b73fb..c0b364ec69ada8f87babae27ee7710474034a90c 100644 (file)
@@ -221,9 +221,9 @@ int scols_column_get_json_type(const struct libscols_column *cl)
  * by this function. If the format is not specified then filter and counters
  * try to use SCOLS_JSON_* types, if also not define than defaults to string.
  *
- * If simple string conversion is not possible then application (which want to
- * use filters and counters) needs to define data function. See
- * scols_column_set_datafunc().
+ * If a simple string conversion is not possible then application (which want
+ * to use filters and counters) needs to define data function to do the
+ * conversion. See scols_column_set_datafunc().
  *
  * Returns: 0, a negative value in case of an error.
  *
@@ -244,7 +244,7 @@ int scols_column_set_data_type(struct libscols_column *cl, int type)
  */
 int scols_column_get_data_type(const struct libscols_column *cl)
 {
-       return cl->data_type;;
+       return cl->data_type;
 }
 /**
  * scols_column_get_table:
index cc2d7af4a49dce463793e6a5eb287292f3a63a9f..eacf18405ae633bbccac97c0e5c649fe56fbfce9 100644 (file)
@@ -227,9 +227,9 @@ int filter_param_reset_holder(struct filter_param *n)
        if (n->type != SCOLS_DATA_NONE)
                return 0; /* already set */
 
-       if (n->col->data_type)
+       if (scols_column_get_data_type(n->col))
                /* use by application defined type */
-               n->type = n->col->data_type;
+               n->type = scols_column_get_data_type(n->col);
        else {
                /* use by JSON defined type, default to string if not specified */
                switch (n->col->json_type) {
@@ -283,7 +283,7 @@ static int fetch_holder_data(struct libscols_filter *fltr __attribute__((__unuse
                if (ce)
                        data = cl->datafunc(n->col, ce, cl->datafunc_data);
                if (data)
-                       rc = param_set_data(n, cl->data_type, data);
+                       rc = param_set_data(n, scols_column_get_data_type(cl), data);
        } else {
                /* read column data, use it as string */
                data = scols_line_get_column_data(ln, n->col);