diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2008-10-27 17:39:38 -0700 |
---|---|---|
committer | Luis R. Rodriguez <lrodriguez@atheros.com> | 2008-10-27 17:39:38 -0700 |
commit | 5b7bba8e7a9970b084a01e5db3c454ddcb1fd54d (patch) | |
tree | 4250d3f4c98d1b6469eb12857d9857e7ead86411 | |
parent | 273df6ab9741b4a8efd5417fa156d6ab5b59b755 (diff) | |
download | crda-5b7bba8e7a9970b084a01e5db3c454ddcb1fd54d.tar.gz crda-5b7bba8e7a9970b084a01e5db3c454ddcb1fd54d.tar.bz2 crda-5b7bba8e7a9970b084a01e5db3c454ddcb1fd54d.zip |
Avoid stdlib, this saves 145 bytes
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
-rw-r--r-- | crda.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -6,7 +6,6 @@ #include <errno.h> #include <stdio.h> -#include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> @@ -95,9 +94,19 @@ static int error_handler(struct sockaddr_nl __attribute__((unused)) *nla, exit(err->error); } +/* Avoid stdlib */ +static int is_len_2(const char *alpha2) +{ + if (alpha2[0] == '\0' || (alpha2[1] == '\0')) + return 0; + if (alpha2[2] == '\0') + return 1; + return 0; +} + static int is_valid_regdom(const char *alpha2) { - if (strlen(alpha2) != 2) + if (!is_len_2(alpha2)) return 0; if (!is_alpha2(alpha2) && !is_world_regdom(alpha2)) |