xfs
[Top] [All Lists]

[PATCH] xfs_quota: check report_mount return value

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs_quota: check report_mount return value
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Wed, 11 May 2016 21:41:12 -0500
Cc: Zorro Lang <zlang@xxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.0
The new call to report_mount doesn't check the return value
like every other caller does...

Returning 1 means it printed something; if the terse flag
is used and there is no usage, nothing gets printed.
If we set the NO_HEADER_FLAG anyway, then we won't see
the header for subsequent entries as we expect.

For example, project ID 0 has no usage in this case:

# xfs_quota -x -c "report -a" /mnt/test
Project quota on /mnt/test (/dev/sdb1)
                               Blocks                     
Project ID       Used       Soft       Hard    Warn/Grace     
---------- -------------------------------------------------- 
#0                  0          0          0     00 [--------]
project          2048          4          4     00 [--none--]

So using the terse flag results in no header when it prints
projects with usage:

# xfs_quota -x -c "report -t -a" /mnt/test
project          2048          4          4     00 [--none--]

With this fix it prints the header as expected:

# xfs_quota -x -c "report -t -a" /mnt/test
Project quota on /mnt/test (/dev/sdb1)
                               Blocks                     
Project ID       Used       Soft       Hard    Warn/Grace     
---------- -------------------------------------------------- 
project          2048          4          4     00 [--none--]


Addresses-Coverity-Id: 1361552
Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/quota/report.c b/quota/report.c
index cc422d1..59290e1 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -580,9 +580,9 @@ report_project_mount(
                         * Print default project quota, even if projid 0
                         * isn't defined
                         */
-                       report_mount(fp, 0, NULL, NULL, form, XFS_PROJ_QUOTA,
-                                    mount, flags);
-                       flags |= NO_HEADER_FLAG;
+                       if (report_mount(fp, 0, NULL, NULL,
+                                       form, XFS_PROJ_QUOTA, mount, flags))
+                               flags |= NO_HEADER_FLAG;
                }
 
                setprent();

<Prev in Thread] Current Thread [Next in Thread>