From 8906c6cd6e1a93297d2f05133fd2d13adf3e4ab6 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Thu, 2 Apr 2020 10:42:42 -0700
Subject: [PATCH] Fix macOS build.

I'd put the rtc_wkalarm struct in the globals to get it zeroed for
free, but since there's no such type on macOS, that breaks the
build. Rather than define a bogus struct in portability.h, I've
gone for making it an explicitly-zeroed local. (And I've sorted the
locals largest-first.)

Note that the use of struct rtc_time as if it was the same as struct
tm in this code follows the existing code in hwclock, but I worry
that we're going to have trouble with that because of the extra
tm_gmtoff and tm_zone fields in struct tm. But that's a worry for
another day...

This patch also removes the CONFIG_CP_PRESERVE from the macos_miniconfig,
since that option was removed a while back.
---
 kconfig/macos_miniconfig | 1 -
 toys/pending/rtcwake.c   | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/kconfig/macos_miniconfig b/kconfig/macos_miniconfig
index b9bf6a3a..71663137 100644
--- a/kconfig/macos_miniconfig
+++ b/kconfig/macos_miniconfig
@@ -11,7 +11,6 @@ CONFIG_CRC32=y
 CONFIG_CMP=y
 CONFIG_COMM=y
 CONFIG_CP=y
-CONFIG_CP_PRESERVE=y
 CONFIG_CPIO=y
 CONFIG_CUT=y
 CONFIG_DATE=y
diff --git a/toys/pending/rtcwake.c b/toys/pending/rtcwake.c
index 0929d51f..0da1de6b 100644
--- a/toys/pending/rtcwake.c
+++ b/toys/pending/rtcwake.c
@@ -37,14 +37,13 @@ config RTCWAKE
 GLOBALS(
   long long t, s;
   char *m, *d;
-
-  struct rtc_wkalrm alarm;
 )
 
 void rtcwake_main(void)
 {
-  time_t now, rtc_now, then;
+  struct rtc_wkalrm alarm = {};
   struct tm rtc_tm;
+  time_t now, rtc_now, then;
   int fd, utc;
 
   if (FLAG(list_modes)) {
-- 
2.24.0.525.g8f36a354ae-goog

