meta-flow: Simplify mf_from_ofp_port_string()
authorJarno Rajahalme <jarno.rajahalme@nsn.com>
Fri, 10 May 2013 19:54:35 +0000 (22:54 +0300)
committerBen Pfaff <blp@nicira.com>
Fri, 10 May 2013 20:37:28 +0000 (13:37 -0700)
ofputil_port_from_string() does all the work already.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/meta-flow.c

index c3f198c..16850ec 100644 (file)
@@ -2168,17 +2168,13 @@ mf_from_ofp_port_string(const struct mf_field *mf, const char *s,
     uint16_t port;
 
     ovs_assert(mf->n_bytes == sizeof(ovs_be16));
-    if (*s == '-') {
-        return xasprintf("%s: negative values not supported for %s",
-                         s, mf->name);
-    } else if (ofputil_port_from_string(s, &port)) {
+
+    if (ofputil_port_from_string(s, &port)) {
         *valuep = htons(port);
         *maskp = htons(UINT16_MAX);
         return NULL;
-    } else {
-        return mf_from_integer_string(mf, s,
-                                      (uint8_t *) valuep, (uint8_t *) maskp);
     }
+    return xasprintf("%s: port value out of range for %s", s, mf->name);
 }
 
 struct frag_handling {