summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Rosen Penev2019-12-08 15:45:19 -0800
committerGravatar Rosen Penev2020-04-12 16:38:17 -0700
commitc0576790378daa45d43335d44c5caff04c270c94 (patch)
treee7e917751cb6f8e373a0e244184a152daf1d8409
parente6a4ab68cb860878b06f51a40cfde44e3971d55e (diff)
downloadlibimobiledevice-c0576790378daa45d43335d44c5caff04c270c94.tar.gz
libimobiledevice-c0576790378daa45d43335d44c5caff04c270c94.tar.bz2
idevicedate: Fix -Wformat=2 warning
Format functions expect a constant expression, not a variable. Simplified the code slightly.
-rw-r--r--tools/idevicedate.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/tools/idevicedate.c b/tools/idevicedate.c
index 4de90b6..6dddc18 100644
--- a/tools/idevicedate.c
+++ b/tools/idevicedate.c
@@ -38,9 +38,9 @@
38#include <libimobiledevice/lockdown.h> 38#include <libimobiledevice/lockdown.h>
39 39
40#ifdef _DATE_FMT 40#ifdef _DATE_FMT
41#define DATE_FMT_LANGINFO() nl_langinfo (_DATE_FMT) 41#define DATE_FMT_LANGINFO nl_langinfo (_DATE_FMT)
42#else 42#else
43#define DATE_FMT_LANGINFO() "" 43#define DATE_FMT_LANGINFO "%a %b %e %H:%M:%S %Z %Y"
44#endif 44#endif
45 45
46static void print_usage(int argc, char **argv) 46static void print_usage(int argc, char **argv)
@@ -75,7 +75,6 @@ int main(int argc, char *argv[])
75 uint64_t datetime = 0; 75 uint64_t datetime = 0;
76 time_t rawtime; 76 time_t rawtime;
77 struct tm * tmp; 77 struct tm * tmp;
78 char const *format = NULL;
79 char buffer[80]; 78 char buffer[80];
80 int result = 0; 79 int result = 0;
81 80
@@ -131,14 +130,6 @@ int main(int argc, char *argv[])
131 } 130 }
132 } 131 }
133 132
134 /* determine a date format */
135 if (!format) {
136 format = DATE_FMT_LANGINFO ();
137 if (!*format) {
138 format = "%a %b %e %H:%M:%S %Z %Y";
139 }
140 }
141
142 ret = idevice_new(&device, udid); 133 ret = idevice_new(&device, udid);
143 if (ret != IDEVICE_E_SUCCESS) { 134 if (ret != IDEVICE_E_SUCCESS) {
144 if (udid) { 135 if (udid) {
@@ -195,7 +186,7 @@ int main(int argc, char *argv[])
195 tmp = localtime(&rawtime); 186 tmp = localtime(&rawtime);
196 187
197 /* finally we format and print the current date */ 188 /* finally we format and print the current date */
198 strftime(buffer, 80, format, tmp); 189 strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
199 puts(buffer); 190 puts(buffer);
200 } else { 191 } else {
201 datetime = setdate; 192 datetime = setdate;
@@ -217,7 +208,7 @@ int main(int argc, char *argv[])
217 208
218 if(lockdownd_set_value(client, NULL, "TimeIntervalSince1970", node) == LOCKDOWN_E_SUCCESS) { 209 if(lockdownd_set_value(client, NULL, "TimeIntervalSince1970", node) == LOCKDOWN_E_SUCCESS) {
219 tmp = localtime(&setdate); 210 tmp = localtime(&setdate);
220 strftime(buffer, 80, format, tmp); 211 strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
221 puts(buffer); 212 puts(buffer);
222 } else { 213 } else {
223 printf("ERROR: Failed to set date on device.\n"); 214 printf("ERROR: Failed to set date on device.\n");