Bladeren bron

Merge pull request #3784 from zhiweih/patch-1

Specify date string length in FINSH date command.
Bernard Xiong 4 jaren geleden
bovenliggende
commit
8ecea29bd2
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      components/drivers/rtc/rtc.c

+ 2 - 2
components/drivers/rtc/rtc.c

@@ -179,7 +179,7 @@ void list_date(void)
     time_t now;
     time_t now;
 
 
     now = time(RT_NULL);
     now = time(RT_NULL);
-    rt_kprintf("%s\n", ctime(&now));
+    rt_kprintf("%.*s\n", 25, ctime(&now));
 }
 }
 FINSH_FUNCTION_EXPORT(list_date, show date and time.)
 FINSH_FUNCTION_EXPORT(list_date, show date and time.)
 
 
@@ -194,7 +194,7 @@ static void date(uint8_t argc, char **argv)
         time_t now;
         time_t now;
         /* output current time */
         /* output current time */
         now = time(RT_NULL);
         now = time(RT_NULL);
-        rt_kprintf("%s", ctime(&now));
+        rt_kprintf("%.*s", 25, ctime(&now));
     }
     }
     else if (argc >= 7)
     else if (argc >= 7)
     {
     {