Browse Source

Silence warnings about poor format usage for quit()

Luke Dashjr 12 years ago
parent
commit
1aa7bee6bc
3 changed files with 15 additions and 27 deletions
  1. 6 6
      api.c
  2. 5 11
      driver-avalon.c
  3. 4 10
      driver-icarus.c

+ 6 - 6
api.c

@@ -3299,28 +3299,28 @@ static void setup_groups()
 			if (colon)
 			if (colon)
 				*colon = '\0';
 				*colon = '\0';
 			applog(LOG_WARNING, "API invalid group name '%s'", ptr);
 			applog(LOG_WARNING, "API invalid group name '%s'", ptr);
-			quit(1, INVAPIGROUPS);
+			quit(1, "%s", INVAPIGROUPS);
 		}
 		}
 
 
 		group = GROUP(*ptr);
 		group = GROUP(*ptr);
 		if (!VALIDGROUP(group)) {
 		if (!VALIDGROUP(group)) {
 			applog(LOG_WARNING, "API invalid group name '%c'", *ptr);
 			applog(LOG_WARNING, "API invalid group name '%c'", *ptr);
-			quit(1, INVAPIGROUPS);
+			quit(1, "%s", INVAPIGROUPS);
 		}
 		}
 
 
 		if (group == PRIVGROUP) {
 		if (group == PRIVGROUP) {
 			applog(LOG_WARNING, "API group name can't be '%c'", PRIVGROUP);
 			applog(LOG_WARNING, "API group name can't be '%c'", PRIVGROUP);
-			quit(1, INVAPIGROUPS);
+			quit(1, "%s", INVAPIGROUPS);
 		}
 		}
 
 
 		if (group == NOPRIVGROUP) {
 		if (group == NOPRIVGROUP) {
 			applog(LOG_WARNING, "API group name can't be '%c'", NOPRIVGROUP);
 			applog(LOG_WARNING, "API group name can't be '%c'", NOPRIVGROUP);
-			quit(1, INVAPIGROUPS);
+			quit(1, "%s", INVAPIGROUPS);
 		}
 		}
 
 
 		if (apigroups[GROUPOFFSET(group)].commands != NULL) {
 		if (apigroups[GROUPOFFSET(group)].commands != NULL) {
 			applog(LOG_WARNING, "API duplicate group name '%c'", *ptr);
 			applog(LOG_WARNING, "API duplicate group name '%c'", *ptr);
-			quit(1, INVAPIGROUPS);
+			quit(1, "%s", INVAPIGROUPS);
 		}
 		}
 
 
 		ptr += 2;
 		ptr += 2;
@@ -3356,7 +3356,7 @@ static void setup_groups()
 					}
 					}
 				} else {
 				} else {
 					applog(LOG_WARNING, "API unknown command '%s' in group '%c'", ptr, group);
 					applog(LOG_WARNING, "API unknown command '%s' in group '%c'", ptr, group);
-					quit(1, INVAPIGROUPS);
+					quit(1, "%s", INVAPIGROUPS);
 				}
 				}
 			}
 			}
 
 

+ 5 - 11
driver-avalon.c

@@ -401,7 +401,6 @@ static void avalon_idle(struct cgpu_info *avalon)
 static void get_options(int this_option_offset, int *baud, int *miner_count,
 static void get_options(int this_option_offset, int *baud, int *miner_count,
 			int *asic_count, int *timeout, int *frequency)
 			int *asic_count, int *timeout, int *frequency)
 {
 {
-	char err_buf[BUFSIZ+1];
 	char buf[BUFSIZ+1];
 	char buf[BUFSIZ+1];
 	char *ptr, *comma, *colon, *colon2, *colon3, *colon4;
 	char *ptr, *comma, *colon, *colon2, *colon3, *colon4;
 	size_t max;
 	size_t max;
@@ -458,10 +457,9 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 		*baud = 19200;
 		*baud = 19200;
 		break;
 		break;
 	default:
 	default:
-		sprintf(err_buf,
+		quit(1,
 			"Invalid avalon-options for baud (%s) "
 			"Invalid avalon-options for baud (%s) "
 			"must be 115200, 57600, 38400 or 19200", buf);
 			"must be 115200, 57600, 38400 or 19200", buf);
-		quit(1, err_buf);
 	}
 	}
 
 
 	if (colon && *colon) {
 	if (colon && *colon) {
@@ -474,11 +472,10 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 			if (tmp > 0 && tmp <= AVALON_DEFAULT_MINER_NUM) {
 			if (tmp > 0 && tmp <= AVALON_DEFAULT_MINER_NUM) {
 				*miner_count = tmp;
 				*miner_count = tmp;
 			} else {
 			} else {
-				sprintf(err_buf,
+				quit(1,
 					"Invalid avalon-options for "
 					"Invalid avalon-options for "
 					"miner_count (%s) must be 1 ~ %d",
 					"miner_count (%s) must be 1 ~ %d",
 					colon, AVALON_DEFAULT_MINER_NUM);
 					colon, AVALON_DEFAULT_MINER_NUM);
-				quit(1, err_buf);
 			}
 			}
 		}
 		}
 
 
@@ -491,11 +488,10 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 			if (tmp > 0 && tmp <= AVALON_DEFAULT_ASIC_NUM)
 			if (tmp > 0 && tmp <= AVALON_DEFAULT_ASIC_NUM)
 				*asic_count = tmp;
 				*asic_count = tmp;
 			else {
 			else {
-				sprintf(err_buf,
+				quit(1,
 					"Invalid avalon-options for "
 					"Invalid avalon-options for "
 					"asic_count (%s) must be 1 ~ %d",
 					"asic_count (%s) must be 1 ~ %d",
 					colon2, AVALON_DEFAULT_ASIC_NUM);
 					colon2, AVALON_DEFAULT_ASIC_NUM);
-				quit(1, err_buf);
 			}
 			}
 
 
 			if (colon3 && *colon3) {
 			if (colon3 && *colon3) {
@@ -507,11 +503,10 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 				if (tmp > 0 && tmp <= 0xff)
 				if (tmp > 0 && tmp <= 0xff)
 					*timeout = tmp;
 					*timeout = tmp;
 				else {
 				else {
-					sprintf(err_buf,
+					quit(1,
 						"Invalid avalon-options for "
 						"Invalid avalon-options for "
 						"timeout (%s) must be 1 ~ %d",
 						"timeout (%s) must be 1 ~ %d",
 						colon3, 0xff);
 						colon3, 0xff);
-					quit(1, err_buf);
 				}
 				}
 				if (colon4 && *colon4) {
 				if (colon4 && *colon4) {
 					tmp = atoi(colon4);
 					tmp = atoi(colon4);
@@ -523,10 +518,9 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
 						*frequency = tmp;
 						*frequency = tmp;
 						break;
 						break;
 					default:
 					default:
-						sprintf(err_buf,
+						quit(1,
 							"Invalid avalon-options for "
 							"Invalid avalon-options for "
 							"frequency must be 256/270/282/300");
 							"frequency must be 256/270/282/300");
-							quit(1, err_buf);
 					}
 					}
 				}
 				}
 			}
 			}

+ 4 - 10
driver-icarus.c

@@ -410,7 +410,6 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
 
 
 static uint32_t mask(int work_division)
 static uint32_t mask(int work_division)
 {
 {
-	char err_buf[BUFSIZ+1];
 	uint32_t nonce_mask = 0x7fffffff;
 	uint32_t nonce_mask = 0x7fffffff;
 
 
 	// yes we can calculate these, but this way it's easy to see what they are
 	// yes we can calculate these, but this way it's easy to see what they are
@@ -428,8 +427,7 @@ static uint32_t mask(int work_division)
 		nonce_mask = 0x1fffffff;
 		nonce_mask = 0x1fffffff;
 		break;
 		break;
 	default:
 	default:
-		sprintf(err_buf, "Invalid2 icarus-options for work_division (%d) must be 1, 2, 4 or 8", work_division);
-		quit(1, err_buf);
+		quit(1, "Invalid2 icarus-options for work_division (%d) must be 1, 2, 4 or 8", work_division);
 	}
 	}
 
 
 	return nonce_mask;
 	return nonce_mask;
@@ -441,7 +439,6 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 	int *work_division = &info->work_division;
 	int *work_division = &info->work_division;
 	int *fpga_count = &info->fpga_count;
 	int *fpga_count = &info->fpga_count;
 
 
-	char err_buf[BUFSIZ+1];
 	char buf[BUFSIZ+1];
 	char buf[BUFSIZ+1];
 	char *ptr, *comma, *colon, *colon2;
 	char *ptr, *comma, *colon, *colon2;
 	size_t max;
 	size_t max;
@@ -485,8 +482,7 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 				*baud = 57600;
 				*baud = 57600;
 				break;
 				break;
 			default:
 			default:
-				sprintf(err_buf, "Invalid icarus-options for baud (%s) must be 115200 or 57600", buf);
-				quit(1, err_buf);
+				quit(1, "Invalid icarus-options for baud (%s) must be 115200 or 57600", buf);
 			}
 			}
 		}
 		}
 
 
@@ -502,8 +498,7 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 					*work_division = tmp;
 					*work_division = tmp;
 					*fpga_count = tmp;	// default to the same
 					*fpga_count = tmp;	// default to the same
 				} else {
 				} else {
-					sprintf(err_buf, "Invalid icarus-options for work_division (%s) must be 1, 2, 4 or 8", colon);
-					quit(1, err_buf);
+					quit(1, "Invalid icarus-options for work_division (%s) must be 1, 2, 4 or 8", colon);
 				}
 				}
 			}
 			}
 
 
@@ -518,8 +513,7 @@ static void get_options(int this_option_offset, struct ICARUS_INFO *info)
 				if (tmp > 0 && tmp <= *work_division)
 				if (tmp > 0 && tmp <= *work_division)
 					*fpga_count = tmp;
 					*fpga_count = tmp;
 				else {
 				else {
-					sprintf(err_buf, "Invalid icarus-options for fpga_count (%s) must be >0 and <=work_division (%d)", colon2, *work_division);
-					quit(1, err_buf);
+					quit(1, "Invalid icarus-options for fpga_count (%s) must be >0 and <=work_division (%d)", colon2, *work_division);
 				}
 				}
 			  }
 			  }