You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9 KiB

  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
  5. Format functions expect a constant expression, not a variable.
  6. Simplified the code slightly.
  7. ---
  8. tools/idevicedate.c | 17 ++++-------------
  9. 1 file changed, 4 insertions(+), 13 deletions(-)
  10. diff --git a/tools/idevicedate.c b/tools/idevicedate.c
  11. index 4de90b63..6dddc185 100644
  12. --- a/tools/idevicedate.c
  13. +++ b/tools/idevicedate.c
  14. @@ -38,9 +38,9 @@
  15. #include <libimobiledevice/lockdown.h>
  16. #ifdef _DATE_FMT
  17. -#define DATE_FMT_LANGINFO() nl_langinfo (_DATE_FMT)
  18. +#define DATE_FMT_LANGINFO nl_langinfo (_DATE_FMT)
  19. #else
  20. -#define DATE_FMT_LANGINFO() ""
  21. +#define DATE_FMT_LANGINFO "%a %b %e %H:%M:%S %Z %Y"
  22. #endif
  23. static void print_usage(int argc, char **argv)
  24. @@ -75,7 +75,6 @@ int main(int argc, char *argv[])
  25. uint64_t datetime = 0;
  26. time_t rawtime;
  27. struct tm * tmp;
  28. - char const *format = NULL;
  29. char buffer[80];
  30. int result = 0;
  31. @@ -131,14 +130,6 @@ int main(int argc, char *argv[])
  32. }
  33. }
  34. - /* determine a date format */
  35. - if (!format) {
  36. - format = DATE_FMT_LANGINFO ();
  37. - if (!*format) {
  38. - format = "%a %b %e %H:%M:%S %Z %Y";
  39. - }
  40. - }
  41. -
  42. ret = idevice_new(&device, udid);
  43. if (ret != IDEVICE_E_SUCCESS) {
  44. if (udid) {
  45. @@ -195,7 +186,7 @@ int main(int argc, char *argv[])
  46. tmp = localtime(&rawtime);
  47. /* finally we format and print the current date */
  48. - strftime(buffer, 80, format, tmp);
  49. + strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
  50. puts(buffer);
  51. } else {
  52. datetime = setdate;
  53. @@ -217,7 +208,7 @@ int main(int argc, char *argv[])
  54. if(lockdownd_set_value(client, NULL, "TimeIntervalSince1970", node) == LOCKDOWN_E_SUCCESS) {
  55. tmp = localtime(&setdate);
  56. - strftime(buffer, 80, format, tmp);
  57. + strftime(buffer, 80, DATE_FMT_LANGINFO, tmp);
  58. puts(buffer);
  59. } else {
  60. printf("ERROR: Failed to set date on device.\n");