* grub-core/fs/zfs/zfs.c: Stylistic fixes.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-07-14 22:48:23 +02:00
parent 1bd57aa343
commit 286fe4b379
2 changed files with 33 additions and 22 deletions

View file

@ -1,3 +1,7 @@
2013-07-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfs.c: Stylistic fixes.
2013-07-14 Vladimir Serbinenko <phcoder@gmail.com> 2013-07-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfs.c: Run emacs indent on file. * grub-core/fs/zfs/zfs.c: Run emacs indent on file.

View file

@ -812,7 +812,7 @@ fill_vdev_info (struct grub_zfs_data *data,
* nvpair is the last pair in the nvlist, NULL is returned. * nvpair is the last pair in the nvlist, NULL is returned.
*/ */
static const char * static const char *
nvlist_next_nvpair(const char *nvl, const char *nvpair) nvlist_next_nvpair (const char *nvl, const char *nvpair)
{ {
const char *nvp; const char *nvp;
int encode_size; int encode_size;
@ -820,24 +820,28 @@ nvlist_next_nvpair(const char *nvl, const char *nvpair)
if (nvl == NULL) if (nvl == NULL)
return NULL; return NULL;
if (nvpair == NULL) { if (nvpair == NULL)
/* skip over header, nvl_version and nvl_nvflag */ {
nvpair = nvl + 4 * 3; /* skip over header, nvl_version and nvl_nvflag */
} else { nvpair = nvl + 4 * 3;
/* skip to the next nvpair */ }
encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair)); else
nvpair += encode_size; {
/*If encode_size equals 0 nvlist_next_nvpair would return /* skip to the next nvpair */
* the same pair received in input, leading to an infinite loop. encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvpair));
* If encode_size is less than 0, this will move the pointer nvpair += encode_size;
* backwards, *possibly* examinining two times the same nvpair /*If encode_size equals 0 nvlist_next_nvpair would return
* and potentially getting into an infinite loop. */ * the same pair received in input, leading to an infinite loop.
if(encode_size <= 0) { * If encode_size is less than 0, this will move the pointer
grub_dprintf ("zfs", "nvpair with size <= 0\n"); * backwards, *possibly* examinining two times the same nvpair
grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); * and potentially getting into an infinite loop. */
return NULL; if(encode_size <= 0)
{
grub_dprintf ("zfs", "nvpair with size <= 0\n");
grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist");
return NULL;
}
} }
}
/* 8 bytes of 0 marks the end of the list */ /* 8 bytes of 0 marks the end of the list */
if (grub_get_unaligned64 (nvpair) == 0) if (grub_get_unaligned64 (nvpair) == 0)
return NULL; return NULL;
@ -867,12 +871,13 @@ nvlist_next_nvpair(const char *nvl, const char *nvpair)
return nvpair; return nvpair;
} }
/* /*
* This function returns 0 on success and 1 on failure. On success, a string * This function returns 0 on success and 1 on failure. On success, a string
* containing the name of nvpair is saved in buf. * containing the name of nvpair is saved in buf.
*/ */
static int static int
nvpair_name(const char *nvp, char **buf, int* buflen) nvpair_name (const char *nvp, char **buf, int *buflen)
{ {
int len; int len;
@ -887,12 +892,13 @@ nvpair_name(const char *nvp, char **buf, int* buflen)
return 0; return 0;
} }
/* /*
* This function retrieves the value of the nvpair in the form of enumerated * This function retrieves the value of the nvpair in the form of enumerated
* type data_type_t. * type data_type_t.
*/ */
static int static int
nvpair_type(const char *nvp) nvpair_type (const char *nvp)
{ {
int name_len, type; int name_len, type;
@ -910,9 +916,10 @@ nvpair_type(const char *nvp)
return type; return type;
} }
static int static int
nvpair_value(const char *nvp,char **val, nvpair_value (const char *nvp,char **val,
grub_size_t *size_out, grub_size_t *nelm_out) grub_size_t *size_out, grub_size_t *nelm_out)
{ {
int name_len,nelm,encode_size; int name_len,nelm,encode_size;