From d8da13bfb3e18073e4ee665c23854c5fd0a4bd6a Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Sun, 4 Oct 2009 18:12:12 +0200 Subject: [PATCH] Simplify the code --- src/lib/valuepair.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/lib/valuepair.c b/src/lib/valuepair.c index 5d5e39f..2f2c73c 100644 --- a/src/lib/valuepair.c +++ b/src/lib/valuepair.c @@ -950,6 +950,8 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value) break; case PW_TYPE_BYTE: + vp->length = 1; + /* * Note that ALL integers are unsigned! */ @@ -959,60 +961,35 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value) fr_strerror_printf("Byte value \"%s\" is larger than 255", value); return NULL; } - vp->length = 1; break; } - - /* - * Look for the named value for the given - * attribute. - */ - if ((dval = dict_valbyname(vp->attribute, value)) == NULL) { - fr_strerror_printf("Unknown value %s for attribute %s", - value, vp->name); - return NULL; - } - vp->vp_integer = dval->value; - vp->length = 1; - break; + goto check_for_value; case PW_TYPE_SHORT: /* * Note that ALL integers are unsigned! */ vp->vp_integer = getint(value, &p); + vp->length = 2; if (!*p) { if (vp->vp_integer > 65535) { fr_strerror_printf("Byte value \"%s\" is larger than 65535", value); return NULL; } - vp->length = 2; break; } - /* - * Look for the named value for the given - * attribute. - */ - if ((dval = dict_valbyname(vp->attribute, value)) == NULL) { - fr_strerror_printf("Unknown value %s for attribute %s", - value, vp->name); - return NULL; - } - vp->vp_integer = dval->value; - vp->length = 2; - break; + goto check_for_value; case PW_TYPE_INTEGER: /* * Note that ALL integers are unsigned! */ vp->vp_integer = getint(value, &p); - if (!*p) { - vp->length = 4; - break; - } + vp->length = 4; + if (!*p) break; + check_for_value: /* * Look for the named value for the given * attribute. @@ -1023,7 +1000,6 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value) return NULL; } vp->vp_integer = dval->value; - vp->length = 4; break; case PW_TYPE_DATE: -- 2.1.4