]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - io/parent.c
xfsprogs: convert to SPDX license tags
[thirdparty/xfsprogs-dev.git] / io / parent.c
index 47faaa00279f69e7d9f681cda3fe7b24675ea710..53ac659f0ff8c6f804239b519771970678d1f952 100644 (file)
@@ -1,28 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2005-2006 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 <xfs/path.h>
-#include <xfs/parent.h>
-#include <xfs/handle.h>
-#include <xfs/jdm.h>
+#include "command.h"
+#include "input.h"
+#include "path.h"
+#include "parent.h"
+#include "handle.h"
+#include "jdm.h"
 #include "init.h"
 #include "io.h"
 
@@ -142,7 +129,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size,
                        break;
                }
        } while (error == ERANGE);
-       
+
 
        if (count == 0) {
                /* no links for inode - something wrong here */
@@ -258,7 +245,8 @@ parent_check(void)
        if (!bstatbuf || !parentbuf) {
                fprintf(stderr, _("unable to allocate buffers: %s\n"),
                        strerror(errno));
-               return 1;
+               err_status = 1;
+               goto out;
        }
 
        if (do_bulkstat(parentbuf, &parentbuf_size, bstatbuf, fsfd, fshandlep) != 0)
@@ -270,8 +258,10 @@ parent_check(void)
                printf(_("succeeded checking %llu inodes\n"),
                        (unsigned long long) inodes_checked);
 
+out:
        free(bstatbuf);
        free(parentbuf);
+       free(fshandlep);
        return err_status;
 }
 
@@ -290,7 +280,7 @@ print_parent_entry(parent_t *parent, int fullpath)
 static int
 parent_list(int fullpath)
 {
-       void *handlep;
+       void *handlep = NULL;
        size_t handlen;
        int error, i;
        int retval = 1;
@@ -310,6 +300,7 @@ parent_list(int fullpath)
                                progname, path, strerror(errno));
                        goto error;
                }
+               free_handle(fshandle, fshlen);
        }
 
        if (path_to_handle(path, &handlep, &handlen) != 0) {
@@ -322,7 +313,7 @@ parent_list(int fullpath)
                if (!parentbuf) {
                        fprintf(stderr, _("%s: unable to allocate parent buffer: %s\n"),
                                progname, strerror(errno));
-                       return 1;
+                       goto error;
                }
 
                if (fullpath) {
@@ -362,6 +353,7 @@ parent_list(int fullpath)
 
        retval = 0;
 error:
+       free(handlep);
        free(parentbuf);
        return retval;
 }