X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_nameval.c;h=18c30b3372c48f9cdf2a7c3c5a81f74b5df7d56f;hp=daa36f989d318bf6dd5684973576a875144d455f;hb=46eb953ecab322d3385ccf84c75d969de8542317;hpb=05f5305b2d17b0e2889338724b864cf80f309437 diff --git a/yaffs_nameval.c b/yaffs_nameval.c index daa36f9..18c30b3 100644 --- a/yaffs_nameval.c +++ b/yaffs_nameval.c @@ -12,15 +12,15 @@ */ /* - * This simple implementation of a name-value store assumes a small number of values and fits - * into a small finite buffer. + * This simple implementation of a name-value store assumes a small number of +* values and fits into a small finite buffer. * * Each attribute is stored as a record: * sizeof(int) bytes record size. * strnlen+1 bytes name null terminated. * nbytes value. * ---------- - * total size stored in record size + * total size stored in record size * * This code has not been tested with unicode yet. */ @@ -29,7 +29,7 @@ #include "yportenv.h" -static int nval_find(const char *xb, int xb_size, const YCHAR * name, +static int nval_find(const char *xb, int xb_size, const YCHAR *name, int *exist_size) { int pos = 0; @@ -70,24 +70,25 @@ static int nval_used(const char *xb, int xb_size) return pos; } -int nval_del(char *xb, int xb_size, const YCHAR * name) +int nval_del(char *xb, int xb_size, const YCHAR *name) { 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 */ + /* 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 { return -ENODATA; - } + } } -int nval_set(char *xb, int xb_size, const YCHAR * name, const char *buf, - int bsize, int flags) +int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf, + int bsize, int flags) { int pos; int namelen = strnlen(name, xb_size); @@ -168,8 +169,10 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize) int filled = 0; memcpy(&size, xb + pos, sizeof(int)); - while (size > sizeof(int) && size <= xb_size && (pos + size) < xb_size - && !filled) { + while (size > sizeof(int) && + size <= xb_size && + (pos + size) < xb_size && + !filled) { pos += sizeof(int); size -= sizeof(int); name_len = strnlen((YCHAR *) (xb + pos), size); @@ -185,7 +188,7 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize) ncopied += (name_len + 1); } else { filled = 1; - } + } pos += size; if (pos < xb_size - sizeof(int)) memcpy(&size, xb + pos, sizeof(int));