]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - quota/edit.c
libfrog: convert scrub.c functions to negative error codes
[thirdparty/xfsprogs-dev.git] / quota / edit.c
index 8418e8587fe7216e12afc05e753972d8f94004fd..f9938b8acbe0a3dc13f71b116bc71c88af073d19 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 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 <pwd.h>
@@ -380,8 +368,7 @@ restore_file(
        uint            type)
 {
        char            buffer[512];
-       char            devbuffer[512];
-       char            *dev = NULL;
+       char            dev[512];
        uint            mask;
        int             cnt;
        uint32_t        id;
@@ -389,7 +376,11 @@ restore_file(
 
        while (fgets(buffer, sizeof(buffer), fp) != NULL) {
                if (strncmp("fs = ", buffer, 5) == 0) {
-                       dev = strncpy(devbuffer, buffer+5, sizeof(devbuffer));
+                       /*
+                        * Copy the device name to dev, strip off the trailing
+                        * newline, and move on to the next line.
+                        */
+                       strncpy(dev, buffer + 5, sizeof(dev) - 1);
                        dev[strlen(dev) - 1] = '\0';
                        continue;
                }