yaffs: Change return value when xattrib delete not found
[yaffs2.git] / yaffs_nameval.c
index 8d0fa4e565ed11f6157ac91f165ba3da30a710be..e75411be9fb7dfef4e3f6866347a35cc88140881 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2010 Aleph One Ltd.
+ * Copyright (C) 2002-2011 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
@@ -50,7 +50,7 @@ static int nval_find(const char *xb, int xb_size, const YCHAR *name,
        }
        if (exist_size)
                *exist_size = 0;
        }
        if (exist_size)
                *exist_size = 0;
-       return -1;
+       return -ENODATA;
 }
 
 static int nval_used(const char *xb, int xb_size)
 }
 
 static int nval_used(const char *xb, int xb_size)
@@ -74,16 +74,15 @@ int nval_del(char *xb, int xb_size, const YCHAR *name)
        int pos = nval_find(xb, xb_size, name, NULL);
        int size;
 
        int pos = nval_find(xb, xb_size, name, NULL);
        int size;
 
-       if (pos >= 0 && pos < xb_size) {
-               /* Find size, shift rest over this record,
-                * then zero out the rest of buffer */
-               memcpy(&size, xb + pos, sizeof(int));
-               memcpy(xb + pos, xb + pos + size, xb_size - (pos + size));
-               memset(xb + (xb_size - size), 0, size);
-               return 0;
-       } else {
+       if (pos < 0 || pos >= xb_size)
                return -ENODATA;
                return -ENODATA;
-       }
+
+       /* Find size, shift rest over this record,
+        * then zero out the rest of buffer */
+       memcpy(&size, xb + pos, sizeof(int));
+       memcpy(xb + pos, xb + pos + size, xb_size - (pos + size));
+       memset(xb + (xb_size - size), 0, size);
+       return 0;
 }
 
 int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf,
 }
 
 int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf,