]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - io/imap.c
xfsprogs: make static things static
[thirdparty/xfsprogs-dev.git] / io / imap.c
index a615467691abe43743cd830e55ae436d746265c7..fbc8e9e1b4605b0d588d0188563c3269a0a45638 100644 (file)
--- a/io/imap.c
+++ b/io/imap.c
@@ -1,30 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2001-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "xfs/xfs.h"
-#include "xfs/command.h"
-#include "xfs/input.h"
+#include "command.h"
+#include "input.h"
 #include "init.h"
 #include "io.h"
 
 static cmdinfo_t imap_cmd;
 
-int
+static int
 imap_f(int argc, char **argv)
 {
        int             count;
@@ -40,6 +27,8 @@ imap_f(int argc, char **argv)
                nent = atoi(argv[1]);
 
        t = malloc(nent * sizeof(*t));
+       if (!t)
+               return 0;
 
        bulkreq.lastip  = &last;
        bulkreq.icount  = nent;
@@ -48,7 +37,7 @@ imap_f(int argc, char **argv)
 
        while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
                if (count == 0)
-                       return 0;
+                       goto out_free;
                for (i = 0; i < count; i++) {
                        printf(_("ino %10llu count %2d mask %016llx\n"),
                                (unsigned long long)t[i].xi_startino,
@@ -58,6 +47,8 @@ imap_f(int argc, char **argv)
        }
        perror("xfsctl(XFS_IOC_FSINUMBERS)");
        exitcode = 1;
+out_free:
+       free(t);
        return 0;
 }
 
@@ -69,7 +60,7 @@ imap_init(void)
        imap_cmd.argmin = 0;
        imap_cmd.argmax = 1;
        imap_cmd.args = _("[nentries]");
-       imap_cmd.flags = CMD_NOMAP_OK;
+       imap_cmd.flags = CMD_NOMAP_OK | CMD_FLAG_ONESHOT;
        imap_cmd.oneline = _("inode map for filesystem of current file");
 
        if (expert)