@@ -266,27 +266,19 @@ static int shell_process(struct shell *p_shell)
266
266
267
267
struct shell_cmd * shell_find_cmd (struct shell * p_shell , const char * cmd_str )
268
268
{
269
- struct shell_cmd * p_cmd ;
270
- bool is_found = false;
271
- struct list_head * pos ;
272
-
273
- p_cmd = NULL ;
269
+ uint32_t i ;
270
+ struct shell_cmd * p_cmd = NULL ;
274
271
275
272
if (p_shell -> cmd_count <= 0 )
276
273
return NULL ;
277
274
278
- list_for_each (pos , & p_shell -> cmd_list ) {
279
- p_cmd = list_entry (pos , struct shell_cmd , node );
280
- pr_dbg ("shell: cmd in registered list is '%s' in %s" ,
281
- p_cmd -> str , __func__ );
282
-
283
- if (strcmp (p_cmd -> str , cmd_str ) == 0 ) {
284
- is_found = true;
275
+ for (i = 0 ; i < p_shell -> cmd_count ; i ++ ) {
276
+ p_cmd = & p_shell -> shell_cmd [i ];
277
+ if (strcmp (p_cmd -> str , cmd_str ) == 0 )
285
278
break ;
286
- }
287
279
}
288
280
289
- if (! is_found ) {
281
+ if (i == p_shell -> cmd_count ) {
290
282
/* No commands in the list. */
291
283
p_cmd = NULL ;
292
284
}
@@ -360,7 +352,7 @@ int shell_process_cmd(struct shell *p_shell, char *p_input_line)
360
352
361
353
/* Determine if there is a command to process. */
362
354
if (cmd_argc != 0 ) {
363
- /* See if command is in the registered command list. */
355
+ /* See if command is in cmds supported */
364
356
p_cmd = shell_find_cmd (p_shell , cmd_argv [0 ]);
365
357
366
358
if (p_cmd != NULL ) {
@@ -412,7 +404,6 @@ int shell_cmd_help(struct shell *p_shell,
412
404
{
413
405
int status = 0 ;
414
406
int spaces = 0 ;
415
- int i ;
416
407
struct shell_cmd * p_cmd = NULL ;
417
408
char space_buf [MAX_INDENT_LEN + 1 ];
418
409
@@ -428,11 +419,11 @@ int shell_cmd_help(struct shell *p_shell,
428
419
/* No registered commands */
429
420
shell_puts (p_shell , "NONE\r\n" );
430
421
} else {
431
- struct list_head * pos ;
422
+ int i = 0 ;
423
+ uint32_t j ;
432
424
433
- i = 0 ;
434
- list_for_each (pos , & p_shell -> cmd_list ) {
435
- p_cmd = list_entry (pos , struct shell_cmd , node );
425
+ for (j = 0 ; j < p_shell -> cmd_count ; j ++ ) {
426
+ p_cmd = & p_shell -> shell_cmd [j ];
436
427
437
428
/* Check if we've filled the screen with info */
438
429
/* i + 1 used to avoid 0%SHELL_ROWS=0 */
@@ -1132,11 +1123,7 @@ int shell_construct(struct shell **p_shell)
1132
1123
/* Allocate memory for shell session */
1133
1124
* p_shell = (struct shell * ) calloc (1 , sizeof (* * p_shell ));
1134
1125
1135
- if (* p_shell ) {
1136
- /* Zero-initialize the service control block. */
1137
- INIT_LIST_HEAD (& (* p_shell )-> cmd_list );
1138
- (* p_shell )-> cmd_count = 0 ;
1139
- } else {
1126
+ if (!(* p_shell )) {
1140
1127
pr_err ("Error: out of memory" );
1141
1128
status = - ENOMEM ;
1142
1129
}
0 commit comments