Browse Source

Move some checks out of parse_cmd().

It is not a good idea parse_cmd() to just die().
Georgi Chorbadzhiyski 9 years ago
parent
commit
6ef51a7374
2 changed files with 15 additions and 22 deletions
  1. 0
    22
      cmd.c
  2. 15
    0
      videohubctrl.c

+ 0
- 22
cmd.c View File

286
 		}
286
 		}
287
 	}
287
 	}
288
 	free(cmd_data);
288
 	free(cmd_data);
289
-
290
-	/* Check if everything is within limits */
291
-	switch (v->cmd) {
292
-	case CMD_VIDEOHUB_DEVICE:
293
-		if (!data->device.dev_present) {
294
-			if (data->device.needs_fw_update) {
295
-				die("Device reports that it needs firmware update.");
296
-			}
297
-			die("Device reports that it's not present.");
298
-		}
299
-		if (data->device.num_video_inputs > ARRAY_SIZE(data->inputs)) {
300
-			die("The device supports %d inputs. Recompile the program with more MAX_INPUTS (currently %d)",
301
-				data->device.num_video_inputs, MAX_INPUTS);
302
-		}
303
-		if (data->device.num_video_outputs > ARRAY_SIZE(data->outputs)) {
304
-			die("The device supports %d outputs. Recompile the program with more MAX_OUTPUTS (currently %d)\n",
305
-				data->device.num_video_outputs, MAX_OUTPUTS);
306
-		}
307
-	default:
308
-		break;
309
-	}
310
-
311
 	return true;
289
 	return true;
312
 }
290
 }
313
 
291
 

+ 15
- 0
videohubctrl.c View File

181
 		die("Device protocol is %s but this program supports 2.x only.\n",
181
 		die("Device protocol is %s but this program supports 2.x only.\n",
182
 			data->device.protocol_ver);
182
 			data->device.protocol_ver);
183
 
183
 
184
+	if (!data->device.dev_present) {
185
+		if (data->device.needs_fw_update) {
186
+			die("Device reports that it needs firmware update.");
187
+		}
188
+		die("Device reports that it's not present.");
189
+	}
190
+
191
+	if (data->device.num_video_inputs > ARRAY_SIZE(data->inputs))
192
+		die("The device supports %d inputs. Recompile the program with more MAX_INPUTS (currently %d)",
193
+			data->device.num_video_inputs, MAX_INPUTS);
194
+
195
+	if (data->device.num_video_outputs > ARRAY_SIZE(data->outputs))
196
+		die("The device supports %d outputs. Recompile the program with more MAX_OUTPUTS (currently %d)\n",
197
+			data->device.num_video_outputs, MAX_OUTPUTS);
198
+
184
 	if (show_monitor) {
199
 	if (show_monitor) {
185
 		while (1) {
200
 		while (1) {
186
 			printf("\e[2J\e[H"); // Clear screen
201
 			printf("\e[2J\e[H"); // Clear screen

Loading…
Cancel
Save