Ignore:
Timestamp:
Aug 30, 2018, 10:26:27 PM (6 years ago)
Author:
viala@…
Message:

Rewrite if-then-else return function into switch case.

For safety reason and performance:

1) Safety: GCC complain with a warning if you forgot an enum variant.
2) code-gen just outperform naive if-then-else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/process.c

    r514 r527  
    456456
    457457/////////////////////////////////////////////////
    458 char * process_action_str( uint32_t action_type )
    459 {
    460     if     ( action_type == BLOCK_ALL_THREADS   ) return "BLOCK";
    461     else if( action_type == UNBLOCK_ALL_THREADS ) return "UNBLOCK";
    462     else if( action_type == DELETE_ALL_THREADS  ) return "DELETE";
    463     else                                          return "undefined";
     458const char * process_action_str( process_sigactions_t action_type )
     459{
     460  switch ( action_type ) {
     461  case BLOCK_ALL_THREADS:   return "BLOCK";
     462  case UNBLOCK_ALL_THREADS: return "UNBLOCK";
     463  case DELETE_ALL_THREADS:  return "DELETE";
     464  default:                  return "undefined";
     465  }
    464466}
    465467
Note: See TracChangeset for help on using the changeset viewer.