]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: use assert() in non-public functions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 1 Oct 2022 06:27:12 +0000 (15:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 2 Oct 2022 14:05:05 +0000 (23:05 +0900)
src/libsystemd-network/dhcp6-option.c

index 5e91e86f536d36ac29fe4d5d774e1cac01a26828..0d26aef234764f4df7dce9d5e86d6da8c7060fe3 100644 (file)
@@ -212,9 +212,9 @@ bool dhcp6_option_can_request(uint16_t option) {
 }
 
 static int option_append_hdr(uint8_t **buf, size_t *buflen, uint16_t optcode, size_t optlen) {
-        assert_return(buf, -EINVAL);
-        assert_return(*buf, -EINVAL);
-        assert_return(buflen, -EINVAL);
+        assert(buf);
+        assert(*buf);
+        assert(buflen);
 
         if (optlen > 0xffff || *buflen < optlen + offsetof(DHCP6Option, data))
                 return -ENOBUFS;
@@ -228,11 +228,16 @@ static int option_append_hdr(uint8_t **buf, size_t *buflen, uint16_t optcode, si
         return 0;
 }
 
-int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
-                        size_t optlen, const void *optval) {
+int dhcp6_option_append(
+                uint8_t **buf,
+                size_t *buflen,
+                uint16_t code,
+                size_t optlen,
+                const void *optval) {
+
         int r;
 
-        assert_return(optval || optlen == 0, -EINVAL);
+        assert(optval || optlen == 0);
 
         r = option_append_hdr(buf, buflen, code, optlen);
         if (r < 0)
@@ -335,10 +340,10 @@ int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia) {
         uint16_t len;
         int r;
 
-        assert_return(buf, -EINVAL);
-        assert_return(*buf, -EINVAL);
-        assert_return(buflen, -EINVAL);
-        assert_return(ia, -EINVAL);
+        assert(buf);
+        assert(*buf);
+        assert(buflen);
+        assert(ia);
 
         /* client should not send set T1 and T2. See, RFC 8415, and issue #18090. */
 
@@ -393,7 +398,10 @@ int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn) {
         uint8_t buffer[1 + DNS_WIRE_FORMAT_HOSTNAME_MAX];
         int r;
 
-        assert_return(buf && *buf && buflen && fqdn, -EINVAL);
+        assert(buf);
+        assert(*buf);
+        assert(buflen);
+        assert(fqdn);
 
         buffer[0] = DHCP6_FQDN_FLAG_S; /* Request server to perform AAAA RR DNS updates */