3535 * 9. 'Insert' to toggle insert mode.
3636 * #endif
3737 * 10. 'Tab' to auto complete.
38- * 11. 'Backspace' to delete character forward
38+ * 11. 'Backspace' to delete character forward
3939 * 12. 'Enter' to execute command.
4040 */
4141
@@ -114,14 +114,14 @@ void finsh_thread_entry_sethook(void (*hook)(void))
114114 *
115115 * @param prompt The new prompt string to set.
116116 *
117- * @return 0 on success, -EINVAL if the prompt is NULL.
117+ * @return 0 on success, -RT_EINVAL if the prompt is NULL.
118118 */
119119int finsh_set_prompt_word (const char * prompt )
120120{
121121 if (!prompt )
122122 {
123123 rt_kprintf ("Invalid prompt!\n" );
124- return - EINVAL ;
124+ return - RT_EINVAL ;
125125 }
126126
127127 rt_memset (finsh_prompt , 0 , sizeof (finsh_prompt ));
@@ -323,7 +323,7 @@ rt_bool_t finsh_get_echo(void)
323323 *
324324 * @param password The new password string to set.
325325 *
326- * @return 0 on success, -EINVAL if the password is NULL or its length is invalid.
326+ * @return 0 on success, -RT_EINVAL if the password is NULL or its length is invalid.
327327 */
328328int finsh_set_password (const char * password )
329329{
@@ -335,14 +335,14 @@ int finsh_set_password(const char *password)
335335 if (!password )
336336 {
337337 rt_kprintf ("Password is NULL!\n" );
338- return - EINVAL ;
338+ return - RT_EINVAL ;
339339 }
340340
341341 len = rt_strlen (password );
342342 if (len > FINSH_PASSWORD_MAX || len < FINSH_PASSWORD_MIN )
343343 {
344344 rt_kprintf ("Password length is less than FINSH_PASSWORD_MIN(%d) or greater than FINSH_PASSWORD_MAX(%d)!\n" , FINSH_PASSWORD_MIN , FINSH_PASSWORD_MAX );
345- return - EINVAL ;
345+ return - RT_EINVAL ;
346346 }
347347
348348 level = rt_hw_interrupt_disable ();
@@ -438,22 +438,22 @@ static struct finsh_history *finsh_history_alloc(char *cmd, size_t cmd_length)
438438 if (i >= FINSH_HISTORY_LINES )
439439 {
440440 rt_kprintf ("No available historical record buffer zone!\n" );
441- return NULL ;
441+ return RT_NULL ;
442442 }
443443#else
444444 history = (struct finsh_history * )rt_malloc (sizeof (* history ));
445445 if (!history )
446446 {
447447 rt_kprintf ("Failed to allocate memory for history!\n" );
448- return NULL ;
448+ return RT_NULL ;
449449 }
450450
451451 history -> cmd = (char * )rt_calloc (1 , cmd_length + 1 );
452452 if (!history -> cmd )
453453 {
454454 rt_free (history );
455455 rt_kprintf ("Failed to allocate memory for history command!\n" );
456- return NULL ;
456+ return RT_NULL ;
457457 }
458458#endif /* !RT_USING_HEAP */
459459
@@ -495,7 +495,7 @@ static struct finsh_history *finsh_history_realloc(struct finsh_history *history
495495 {
496496 rt_free (history );
497497 rt_kprintf ("Failed to allocate memory for history command!\n" );
498- return NULL ;
498+ return RT_NULL ;
499499 }
500500#endif /* RT_USING_HEAP */
501501
@@ -524,22 +524,22 @@ static struct finsh_snapshot *finsh_snapshot_alloc(char *cmd, size_t cmd_length,
524524 if (i >= FINSH_SNAPSHOT_DEPTH )
525525 {
526526 rt_kprintf ("No available snapshot buffer zone!\n" );
527- return NULL ;
527+ return RT_NULL ;
528528 }
529529#else
530530 snap = (struct finsh_snapshot * )rt_malloc (sizeof (* snap ));
531531 if (!snap )
532532 {
533533 rt_kprintf ("Failed to allocate memory for snapshot!\n" );
534- return NULL ;
534+ return RT_NULL ;
535535 }
536536
537537 snap -> cmd = (char * )rt_calloc (1 , cmd_length + 1 );
538538 if (!snap -> cmd )
539539 {
540540 rt_free (snap );
541541 rt_kprintf ("Failed to allocate memory for snapshot command!\n" );
542- return NULL ;
542+ return RT_NULL ;
543543 }
544544#endif /* !RT_USING_HEAP */
545545
@@ -583,7 +583,7 @@ static struct finsh_snapshot *finsh_snapshot_realloc(struct finsh_snapshot *snap
583583 {
584584 rt_free (snap );
585585 rt_kprintf ("Failed to allocate memory for snapshot command!\n" );
586- return NULL ;
586+ return RT_NULL ;
587587 }
588588#endif /* RT_USING_HEAP */
589589
@@ -610,7 +610,7 @@ static int finsh_shell_init(void)
610610 if (ret )
611611 {
612612 rt_kprintf ("Failed to initialize shell_rx_notice semaphore!\n" );
613- return - EIO ;
613+ return - RT_EIO ;
614614 }
615615
616616 shell -> input_state = FINSH_INPUT_STATE_NORMAL ;
@@ -669,7 +669,7 @@ static int finsh_shell_init(void)
669669 {
670670 rt_sem_detach (& shell -> rx_notice );
671671 rt_kprintf ("Finsh: can not find device!\n" );
672- return - ENODEV ;
672+ return - RT_ENOENT ;
673673 }
674674#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */
675675
@@ -731,10 +731,11 @@ char finsh_getchar(void)
731731{
732732#ifdef RT_USING_DEVICE
733733 char ch ;
734- int ret ;
735734#ifdef RT_USING_POSIX_STDIO
736735 return (read (rt_posix_stdio_get_console (), & ch , 1 ) > 0 ) ? ch : -1 ;
737736#else
737+ int ret ;
738+
738739 RT_ASSERT (shell != NULL );
739740
740741 if (!shell -> device )
@@ -1597,8 +1598,11 @@ __declspec(allocate("FSymTab$z")) const struct finsh_syscall __fsym_end = {
15971598 */
15981599int finsh_system_init (void )
15991600{
1601+ rt_ubase_t * ptr_begin , * ptr_end ;
16001602 rt_thread_t tid ;
1603+ #ifndef RT_USING_HEAP
16011604 int ret ;
1605+ #endif /* RT_USING_HEAP */
16021606
16031607 if (shell )
16041608 {
@@ -1621,7 +1625,6 @@ int finsh_system_init(void)
16211625#elif defined(__ADSPBLACKFIN__ ) /* for VisualDSP++ Compiler */
16221626 finsh_system_function_init (& __fsymtab_start , & __fsymtab_end );
16231627#elif defined(_MSC_VER )
1624- rt_ubase_t * ptr_begin , * ptr_end ;
16251628
16261629 ptr_begin = (rt_ubase_t * )& __fsym_begin ;
16271630 ptr_begin += (sizeof (struct finsh_syscall ) / sizeof (rt_ubase_t ));
@@ -1642,14 +1645,14 @@ int finsh_system_init(void)
16421645 if (!shell )
16431646 {
16441647 rt_kprintf ("No memory for shell!\n" );
1645- return - ENOMEM ;
1648+ return - RT_ENOMEM ;
16461649 }
16471650 tid = rt_thread_create (FINSH_THREAD_NAME , finsh_thread_entry , NULL , FINSH_THREAD_STACK_SIZE , FINSH_THREAD_PRIORITY , 10 );
16481651 if (!tid )
16491652 {
16501653 rt_free (shell );
16511654 rt_kprintf ("Create finsh thread failed!\n" );
1652- return - ENOMEM ;
1655+ return - RT_ENOMEM ;
16531656 }
16541657#else
16551658 ret = rt_thread_init (& finsh_thread , FINSH_THREAD_NAME , finsh_thread_entry , NULL , & finsh_thread_stack [0 ], sizeof (finsh_thread_stack ), FINSH_THREAD_PRIORITY , 10 );
0 commit comments