]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fincore: check rc from smartcols stuff [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 11:08:33 +0000 (13:08 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 11:08:33 +0000 (13:08 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/fincore.c

index 6a29f375a4c0cdddf6feae206379092d7c8f5bcd..28103ad5d156777caca950fa5fd84cb22ed2fb95 100644 (file)
@@ -123,13 +123,15 @@ static int add_output_data(struct fincore_control *ctl,
                err(EXIT_FAILURE, _("failed to initialize output line"));
 
        for (i = 0; i < ncolumns; i++) {
+               int rc = 0;
+
                switch(get_column_id(i)) {
                case COL_FILE:
-                       scols_line_set_data(ln, i, name);
+                       rc = scols_line_set_data(ln, i, name);
                        break;
                case COL_PAGES:
                        xasprintf(&tmp, "%jd",  (intmax_t) count_incore);
-                       scols_line_refer_data(ln, i, tmp);
+                       rc = scols_line_refer_data(ln, i, tmp);
                        break;
                case COL_RES:
                {
@@ -139,7 +141,7 @@ static int add_output_data(struct fincore_control *ctl,
                                xasprintf(&tmp, "%ju", res);
                        else
                                tmp = size_to_human_string(SIZE_SUFFIX_1LETTER, res);
-                       scols_line_refer_data(ln, i, tmp);
+                       rc = scols_line_refer_data(ln, i, tmp);
                        break;
                }
                case COL_SIZE:
@@ -147,11 +149,14 @@ static int add_output_data(struct fincore_control *ctl,
                                xasprintf(&tmp, "%jd", (intmax_t) file_size);
                        else
                                tmp = size_to_human_string(SIZE_SUFFIX_1LETTER, file_size);
-                       scols_line_refer_data(ln, i, tmp);
+                       rc = scols_line_refer_data(ln, i, tmp);
                        break;
                default:
                        return -EINVAL;
                }
+
+               if (rc)
+                       err(EXIT_FAILURE, _("failed to add output data"));
        }
 
        return 0;