summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-07-23 01:52:18 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-07-23 01:52:18 +0200
commit15b0a9229431dc75425c229b2f94e680db49d594 (patch)
tree3928d3d261fd993096bd8c85edd58399870ecee7 /lib
parentd843c274781bf9d30bfba93229b9f02a88f26fe2 (diff)
RPKI: Fix reconfiguration when ssh parameters are undefined
Diffstat (limited to 'lib')
-rw-r--r--lib/printf_test.c14
-rw-r--r--lib/string.h9
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/printf_test.c b/lib/printf_test.c
index 10d284ac..341fde9c 100644
--- a/lib/printf_test.c
+++ b/lib/printf_test.c
@@ -89,6 +89,19 @@ t_time(void)
return 1;
}
+static int
+t_bstrcmp(void)
+{
+ bt_assert(bstrcmp("aa", "aa") == 0);
+ bt_assert(bstrcmp("aa", "bb") == -1);
+ bt_assert(bstrcmp("bb", "aa") == 1);
+ bt_assert(bstrcmp(NULL, NULL) == 0);
+ bt_assert(bstrcmp(NULL, "bb") == -1);
+ bt_assert(bstrcmp("bb", NULL) == 1);
+
+ return 1;
+}
+
int
main(int argc, char *argv[])
{
@@ -97,6 +110,7 @@ main(int argc, char *argv[])
bt_test_suite(t_simple, "printf without varargs");
bt_test_suite(t_router_id, "print router id");
bt_test_suite(t_time, "print time");
+ bt_test_suite(t_bstrcmp, "bstrcmp");
return bt_exit_value();
}
diff --git a/lib/string.h b/lib/string.h
index 0d34f9c5..bd4fd2a0 100644
--- a/lib/string.h
+++ b/lib/string.h
@@ -60,6 +60,15 @@ memset32(void *D, u32 val, uint n)
dst[i] = val;
}
+static inline int
+bstrcmp(const char *s1, const char *s2)
+{
+ if (s1 && s2)
+ return strcmp(s1, s2);
+ else
+ return !s2 - !s1;
+}
+
#define ROUTER_ID_64_LENGTH 23
#endif