chiark / gitweb /
test-dhcp-option: add assert to check index is nonnegative
[elogind.git] / src / libsystemd-network / test-dhcp-option.c
index eac3844f96b8ad620c0f116b4cc46bbca3598707..bd448ff2b20dc868056d8c0378f9f146a5a1adef 100644 (file)
@@ -3,7 +3,6 @@
 #include <stdbool.h>
 #include <errno.h>
 #include <string.h>
-#include <assert.h>
 
 #include "util.h"
 #include "macro.h"
@@ -131,6 +130,8 @@ static DHCPMessage *create_message(uint8_t *options, uint16_t optlen,
 
 static void test_ignore_opts(uint8_t *descoption, int *descpos, int *desclen)
 {
+        assert(*descpos >= 0);
+
         while (*descpos < *desclen) {
                 switch(descoption[*descpos]) {
                 case DHCP_OPTION_PAD:
@@ -344,7 +345,7 @@ static void test_option_set(void)
 
         for (i = 0; i < 9; i++) {
                 if (verbose)
-                        printf("%2d: 0x%02x(0x%02x) (options)\n", i, result->options[i],
+                        printf("%2u: 0x%02x(0x%02x) (options)\n", i, result->options[i],
                                options[i]);
                 assert_se(result->options[i] == options[i]);
         }
@@ -363,7 +364,7 @@ static void test_option_set(void)
 
         for (i = 0; i < pos - 8; i++) {
                 if (verbose)
-                        printf("%2d: 0x%02x(0x%02x) (sname)\n", i, result->sname[i],
+                        printf("%2u: 0x%02x(0x%02x) (sname)\n", i, result->sname[i],
                                options[i + 9]);
                 assert_se(result->sname[i] == options[i + 9]);
         }