1 From ec2bba4ffe5a0939ba192b014ba594eaa964412f Mon Sep 17 00:00:00 2001
2 From: Rosen Penev <rosenp@gmail.com>
3 Date: Sun, 8 Dec 2019 15:45:19 -0800
4 Subject: [PATCH] idevicedate: Fix -Wformat=2 warning
6 Format functions expect a constant expression, not a variable.
8 Simplified the code slightly.
10 tools/idevicedate.c | 17 ++++-------------
11 1 file changed, 4 insertions(+), 13 deletions(-)
13 diff --git a/tools/idevicedate.c b/tools/idevicedate.c
14 index 4de90b63..6dddc185 100644
15 --- a/tools/idevicedate.c
16 +++ b/tools/idevicedate.c
18 #include <libimobiledevice/lockdown.h>
21 -#define DATE_FMT_LANGINFO() nl_langinfo (_DATE_FMT)
22 +#define DATE_FMT_LANGINFO nl_langinfo (_DATE_FMT)
24 -#define DATE_FMT_LANGINFO() ""
25 +#define DATE_FMT_LANGINFO "%a %b %e %H:%M:%S %Z %Y"
28 static void print_usage(int argc, char **argv)
29 @@ -75,7 +75,6 @@ int main(int argc, char *argv[])
30 uint64_t datetime = 0;
33 - char const *format = NULL;
37 @@ -131,14 +130,6 @@ int main(int argc, char *argv[])
41 - /* determine a date format */
43 - format = DATE_FMT_LANGINFO ();
45 - format = "%a %b %e %H:%M:%S %Z %Y";
49 ret = idevice_new(&device, udid);
50 if (ret != IDEVICE_E_SUCCESS) {
52 @@ -195,7 +186,7 @@ int main(int argc, char *argv[])
53 tmp = localtime(&rawtime);
55 /* finally we format and print the current date */
56 - strftime(buffer, 80, format, tmp);
57 + strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
61 @@ -217,7 +208,7 @@ int main(int argc, char *argv[])
63 if(lockdownd_set_value(client, NULL, "TimeIntervalSince1970", node) == LOCKDOWN_E_SUCCESS) {
64 tmp = localtime(&setdate);
65 - strftime(buffer, 80, format, tmp);
66 + strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
69 printf("ERROR: Failed to set date on device.\n");