Submitted By:            Douglas R. Reno <renodr at linuxfromscratch dot org>
Date:                    2021-04-27
Initial Package Version: 247
Origin:                  Upstream (https://github.com/systemd/systemd/commit/ab1aa6368a883bce88e3162fee2bea14aacedf23)
Upstream Status:         Applied 
Description:             Fixes compiling systemd-247 with Linux-5.11.14 and
                         higher. This is due to kernel API changes. systemd-248
                         is going to require the same fix. This particular fix
                         will hold us over until things have calmed down to the
                         point where it is safe to put in the new systemd.

diff -Naurp systemd-247.orig/src/rfkill/rfkill.c systemd-247/src/rfkill/rfkill.c
--- systemd-247.orig/src/rfkill/rfkill.c	2021-04-27 12:20:36.510527124 -0500
+++ systemd-247/src/rfkill/rfkill.c	2021-04-27 12:22:18.869654062 -0500
@@ -178,7 +178,7 @@ static int load_state(Context *c, const
         ssize_t l = write(c->rfkill_fd, &we, sizeof(we));
         if (l < 0)
                 return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
-        if (l < RFKILL_EVENT_SIZE_V1)
+        if ((size_t)l < RFKILL_EVENT_SIZE_V1) /* l cannot be < 0 here. Cast to fix -Werror=sign-compare */
                 return log_error_errno(SYNTHETIC_ERRNO(EIO),
                                        "Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).",
                                        l, sizeof we);
@@ -336,9 +336,9 @@ static int run(int argc, char *argv[]) {
                         break;
                 }
 
-                if (l < RFKILL_EVENT_SIZE_V1)
-                        return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %d)",
-                                               l, RFKILL_EVENT_SIZE_V1);
+                if ((size_t)l < RFKILL_EVENT_SIZE_V1) /* l cannot be < 0 here. Cast to fix -Werror=sign-compare */
+                        return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %zu)",
+                                               l, (size_t) RFKILL_EVENT_SIZE_V1); /* Casting necessary to make compiling with different kernel versions happy */
                 log_debug("Reading struct rfkill_event: got %zd bytes.", l);
 
                 /* The event structure has more fields. We only care about the first few, so it's OK if we
