- if (!strcmp(st, SysD_State_Active))
- resu = SysD_State_Active;
- else if (!strcmp(st, SysD_State_Reloading))
- resu = SysD_State_Reloading;
- else if (!strcmp(st, SysD_State_Inactive))
- resu = SysD_State_Inactive;
- else if (!strcmp(st, SysD_State_Failed))
- resu = SysD_State_Failed;
- else if (!strcmp(st, SysD_State_Activating))
- resu = SysD_State_Activating;
- else if (!strcmp(st, SysD_State_Deactivating))
- resu = SysD_State_Deactivating;
- else {
- errno = EBADMSG;
- resu = NULL;
+ switch (st[0]) {
+ case 'a':
+ if (!strcmp(st, sds_state_names[SysD_State_Active]))
+ resu = SysD_State_Active;
+ else if (!strcmp(st, sds_state_names[SysD_State_Activating]))
+ resu = SysD_State_Activating;
+ break;
+ case 'd':
+ if (!strcmp(st, sds_state_names[SysD_State_Deactivating]))
+ resu = SysD_State_Deactivating;
+ break;
+ case 'f':
+ if (!strcmp(st, sds_state_names[SysD_State_Failed]))
+ resu = SysD_State_Failed;
+ break;
+ case 'i':
+ if (!strcmp(st, sds_state_names[SysD_State_Inactive]))
+ resu = SysD_State_Inactive;
+ break;
+ case 'r':
+ if (!strcmp(st, sds_state_names[SysD_State_Reloading]))
+ resu = SysD_State_Reloading;
+ break;
+ default:
+ break;