Commits

Alexander Dahl committed c4043e2

initial with just style fixes

Comments (0)

Files changed (4)

netcalc-add-braces.patch

+# HG changeset patch
+# Parent fa6f38bd0352a158ff1f3ccef42d6160eaa8446b
+
+diff -r fa6f38bd0352 base/netcalc.c
+--- a/base/netcalc.c	Wed Nov 06 08:43:36 2013 +0100
++++ b/base/netcalc.c	Wed Nov 06 08:48:52 2013 +0100
+@@ -118,7 +118,7 @@
+     if (strspn(s, "0123456789.") == len) {
+         return parseIPv4Address(s, result);
+     }
+-    else
++    else {
+         if (strspn(s, "0123456789abcdefABCDEF:.") == len) {
+             return parseIPv6Address(s, result);
+         }
+@@ -126,6 +126,7 @@
+             result->type = ERR_INVALID_ADDRESS;
+             return FALSE;
+         }
++    }
+ }
+ 
+ /**
+@@ -843,7 +844,7 @@
+     if (argc < minArg || argc > minArg + 1) {
+         return usage(argv[0]);
+     }
+-    else
++    else {
+         if (argc == minArg) {
+             parseAddressWithMask(argv[2], &addr);
+             err = argv[2];
+@@ -867,14 +868,16 @@
+                         ? ERR_INVALID_NETMASK : mask.type;
+                 }
+             }
+-            else
++            else {
+                 if (parseAddressWithMask(argv[2], &addr)) {
+                     return usage(argv[0]);
+                 }
+                 else {
+                     err = argv[2];
+                 }
++            }
+         }
++    }
+ 
+     if (strcmp(argv[1], "canonicalize") == 0) {
+         return makeResult(&addr, err, TRUE);

netcalc-fix-indent.patch

+# HG changeset patch
+# Parent 3536e2653b1254632c5d6dfe8ebb3a499b5358b3
+
+diff -r 3536e2653b12 base/netcalc.c
+--- a/base/netcalc.c	Wed Nov 06 08:25:33 2013 +0100
++++ b/base/netcalc.c	Wed Nov 06 08:43:36 2013 +0100
+@@ -119,13 +119,13 @@
+         return parseIPv4Address(s, result);
+     }
+     else
+-    if (strspn(s, "0123456789abcdefABCDEF:.") == len) {
+-        return parseIPv6Address(s, result);
+-    }
+-    else {
+-        result->type = ERR_INVALID_ADDRESS;
+-        return FALSE;
+-    }
++        if (strspn(s, "0123456789abcdefABCDEF:.") == len) {
++            return parseIPv6Address(s, result);
++        }
++        else {
++            result->type = ERR_INVALID_ADDRESS;
++            return FALSE;
++        }
+ }
+ 
+ /**
+@@ -844,37 +844,37 @@
+         return usage(argv[0]);
+     }
+     else
+-    if (argc == minArg) {
+-        parseAddressWithMask(argv[2], &addr);
+-        err = argv[2];
+-    }
+-    else {
+-        if (parseAddressWithoutMask(argv[2], &addr)) {
+-            struct Address mask;
+-            if (parseAddressWithoutMask(argv[3], &mask)
+-                    && convertNetmaskToCIDR(&mask)) {
+-                if (addr.type == mask.type) {
+-                    addr.netmaskbits = mask.netmaskbits;
++        if (argc == minArg) {
++            parseAddressWithMask(argv[2], &addr);
++            err = argv[2];
++        }
++        else {
++            if (parseAddressWithoutMask(argv[2], &addr)) {
++                struct Address mask;
++                if (parseAddressWithoutMask(argv[3], &mask)
++                        && convertNetmaskToCIDR(&mask)) {
++                    if (addr.type == mask.type) {
++                        addr.netmaskbits = mask.netmaskbits;
++                    }
++                    else {
++                        fprintf(stderr, "address and netmask must belong to the same address family\n");
++                        return -ERR_INVALID_NETMASK + 1;
++                    }
+                 }
+                 else {
+-                    fprintf(stderr, "address and netmask must belong to the same address family\n");
+-                    return -ERR_INVALID_NETMASK + 1;
++                    err = argv[3];
++                    addr.type = mask.type == ERR_INVALID_ADDRESS
++                        ? ERR_INVALID_NETMASK : mask.type;
+                 }
+             }
+-            else {
+-                err = argv[3];
+-                addr.type = mask.type == ERR_INVALID_ADDRESS
+-                    ? ERR_INVALID_NETMASK : mask.type;
+-            }
++            else
++                if (parseAddressWithMask(argv[2], &addr)) {
++                    return usage(argv[0]);
++                }
++                else {
++                    err = argv[2];
++                }
+         }
+-        else
+-        if (parseAddressWithMask(argv[2], &addr)) {
+-            return usage(argv[0]);
+-        }
+-        else {
+-            err = argv[2];
+-        }
+-    }
+ 
+     if (strcmp(argv[1], "canonicalize") == 0) {
+         return makeResult(&addr, err, TRUE);
+netcalc-fix-indent.patch
+netcalc-add-braces.patch
+9da4f75a2302b46ca833021ffbf8d1435633f138:netcalc-fix-indent.patch
+1657db80ca788eeb23124e12fd7555b98b2b3ff5:netcalc-add-braces.patch