@@ -1146,14 +1146,8 @@ static struct ipmi_smi_watcher smi_watcher = {
11461146 .smi_gone = ipmi_smi_gone
11471147};
11481148
1149- static int action_op (const char * inval , char * outval )
1149+ static int action_op_set_val (const char * inval )
11501150{
1151- if (outval )
1152- strcpy (outval , action );
1153-
1154- if (!inval )
1155- return 0 ;
1156-
11571151 if (strcmp (inval , "reset" ) == 0 )
11581152 action_val = WDOG_TIMEOUT_RESET ;
11591153 else if (strcmp (inval , "none" ) == 0 )
@@ -1164,18 +1158,26 @@ static int action_op(const char *inval, char *outval)
11641158 action_val = WDOG_TIMEOUT_POWER_DOWN ;
11651159 else
11661160 return - EINVAL ;
1167- strcpy (action , inval );
11681161 return 0 ;
11691162}
11701163
1171- static int preaction_op (const char * inval , char * outval )
1164+ static int action_op (const char * inval , char * outval )
11721165{
1166+ int rv ;
1167+
11731168 if (outval )
1174- strcpy (outval , preaction );
1169+ strcpy (outval , action );
11751170
11761171 if (!inval )
11771172 return 0 ;
1173+ rv = action_op_set_val (inval );
1174+ if (!rv )
1175+ strcpy (action , inval );
1176+ return rv ;
1177+ }
11781178
1179+ static int preaction_op_set_val (const char * inval )
1180+ {
11791181 if (strcmp (inval , "pre_none" ) == 0 )
11801182 preaction_val = WDOG_PRETIMEOUT_NONE ;
11811183 else if (strcmp (inval , "pre_smi" ) == 0 )
@@ -1188,18 +1190,26 @@ static int preaction_op(const char *inval, char *outval)
11881190 preaction_val = WDOG_PRETIMEOUT_MSG_INT ;
11891191 else
11901192 return - EINVAL ;
1191- strcpy (preaction , inval );
11921193 return 0 ;
11931194}
11941195
1195- static int preop_op (const char * inval , char * outval )
1196+ static int preaction_op (const char * inval , char * outval )
11961197{
1198+ int rv ;
1199+
11971200 if (outval )
1198- strcpy (outval , preop );
1201+ strcpy (outval , preaction );
11991202
12001203 if (!inval )
12011204 return 0 ;
1205+ rv = preaction_op_set_val (inval );
1206+ if (!rv )
1207+ strcpy (preaction , inval );
1208+ return 0 ;
1209+ }
12021210
1211+ static int preop_op_set_val (const char * inval )
1212+ {
12031213 if (strcmp (inval , "preop_none" ) == 0 )
12041214 preop_val = WDOG_PREOP_NONE ;
12051215 else if (strcmp (inval , "preop_panic" ) == 0 )
@@ -1208,7 +1218,22 @@ static int preop_op(const char *inval, char *outval)
12081218 preop_val = WDOG_PREOP_GIVE_DATA ;
12091219 else
12101220 return - EINVAL ;
1211- strcpy (preop , inval );
1221+ return 0 ;
1222+ }
1223+
1224+ static int preop_op (const char * inval , char * outval )
1225+ {
1226+ int rv ;
1227+
1228+ if (outval )
1229+ strcpy (outval , preop );
1230+
1231+ if (!inval )
1232+ return 0 ;
1233+
1234+ rv = preop_op_set_val (inval );
1235+ if (!rv )
1236+ strcpy (preop , inval );
12121237 return 0 ;
12131238}
12141239
@@ -1245,18 +1270,18 @@ static int __init ipmi_wdog_init(void)
12451270{
12461271 int rv ;
12471272
1248- if (action_op (action , NULL )) {
1273+ if (action_op_set_val (action )) {
12491274 action_op ("reset" , NULL );
12501275 pr_info ("Unknown action '%s', defaulting to reset\n" , action );
12511276 }
12521277
1253- if (preaction_op (preaction , NULL )) {
1278+ if (preaction_op_set_val (preaction )) {
12541279 preaction_op ("pre_none" , NULL );
12551280 pr_info ("Unknown preaction '%s', defaulting to none\n" ,
12561281 preaction );
12571282 }
12581283
1259- if (preop_op (preop , NULL )) {
1284+ if (preop_op_set_val (preop )) {
12601285 preop_op ("preop_none" , NULL );
12611286 pr_info ("Unknown preop '%s', defaulting to none\n" , preop );
12621287 }
0 commit comments