goto done;
} else {
char *ns, *tok;
+ int error = 0;
ns = talloc_strdup(mem_ctx, nodestring);
if (ns == NULL) {
uint32_t pnn;
char *endptr;
- pnn = (uint32_t)strtoul(tok, &endptr, 0);
- if (pnn == 0 && tok == endptr) {
+ pnn = (uint32_t)strtoul_err(tok, &endptr, 0, &error);
+ if (error != 0 || (pnn == 0 && tok == endptr)) {
fprintf(stderr, "Invalid node %s\n", tok);
return false;
}
struct ctdb_dbid *db = NULL;
uint32_t id = 0;
const char *name = NULL;
- int ret, i;
+ int i;
+ int ret = 0;
ret = ctdb_ctrl_get_dbmap(mem_ctx, ctdb->ev, ctdb->client,
ctdb->pnn, TIMEOUT(), &dbmap);
}
if (strncmp(db_arg, "0x", 2) == 0) {
- id = strtoul(db_arg, NULL, 0);
+ id = strtoul_err(db_arg, NULL, 0, &ret);
+ if (ret != 0) {
+ return false;
+ }
for (i=0; i<dbmap->num; i++) {
if (id == dbmap->dbs[i].db_id) {
db = &dbmap->dbs[i];
{
struct ctdb_var_list *tun_var_list;
struct ctdb_tunable tunable;
- int ret, i;
bool found;
+ int i;
+ int ret = 0;
if (argc != 2) {
usage("setvar");
}
tunable.name = argv[0];
- tunable.value = strtoul(argv[1], NULL, 0);
+ tunable.value = strtoul_err(argv[1], NULL, 0, &ret);
+ if (ret != 0) {
+ return ret;
+ }
ret = ctdb_ctrl_set_tunable(mem_ctx, ctdb->ev, ctdb->client,
ctdb->cmd_pnn, TIMEOUT(), &tunable);
{
pid_t pid;
uint64_t srvid = 0;
- int ret, status;
+ int status;
+ int ret = 0;
if (argc != 1 && argc != 2) {
usage("process-exists");
pid = atoi(argv[0]);
if (argc == 2) {
- srvid = strtoull(argv[1], NULL, 0);
+ srvid = strtoull_err(argv[1], NULL, 0, &ret);
+ if (ret != 0) {
+ return ret;
+ }
}
if (srvid == 0) {
int argc, const char **argv)
{
struct ctdb_ban_state ban_state;
- int ret;
+ int ret = 0;
if (argc != 1) {
usage("ban");
}
ban_state.pnn = ctdb->cmd_pnn;
- ban_state.time = strtoul(argv[0], NULL, 0);
+ ban_state.time = strtoul_err(argv[0], NULL, 0, &ret);
+ if (ret != 0) {
+ return ret;
+ }
if (ban_state.time == 0) {
fprintf(stderr, "Ban time cannot be zero\n");
ctdb_sock_addr addr;
struct ctdb_tickle_list *tickles;
unsigned port = 0;
- int ret, i;
+ int i;
+ int ret = 0;
if (argc < 1 || argc > 2) {
usage("gettickles");
}
if (argc == 2) {
- port = strtoul(argv[1], NULL, 10);
+ port = strtoul_err(argv[1], NULL, 10, &ret);
+ if (ret != 0) {
+ return ret;
+ }
}
ret = ctdb_sock_addr_from_string(argv[0], &addr, false);
{
ctdb_sock_addr addr;
uint32_t pnn;
- int ret, retries = 0;
+ int retries = 0;
+ int ret = 0;
if (argc != 2) {
usage("moveip");
return 1;
}
- pnn = strtoul(argv[1], NULL, 10);
- if (pnn == CTDB_UNKNOWN_PNN) {
+ pnn = strtoul_err(argv[1], NULL, 10, &ret);
+ if (pnn == CTDB_UNKNOWN_PNN || ret != 0) {
fprintf(stderr, "Invalid PNN %s\n", argv[1]);
return 1;
}
struct ctdb_ltdb_header header;
uint8_t header_buf[sizeof(struct ctdb_ltdb_header)];
size_t np;
- int ret;
+ int ret = 0;
if (argc < 3 || argc > 5) {
usage("tstore");
ZERO_STRUCT(header);
if (argc > 3) {
- header.rsn = (uint64_t)strtoull(argv[3], NULL, 0);
+ header.rsn = (uint64_t)strtoull_err(argv[3], NULL, 0, &ret);
+ if (ret != 0) {
+ return ret;
+ }
}
if (argc > 4) {
header.dmaster = (uint32_t)atol(argv[4]);
const struct ctdb_cmd *cmd;
int loglevel;
bool ok;
- int ret;
+ int ret = 0;
setlinebuf(stdout);
ctdb_timeout = getenv("CTDB_TIMEOUT");
if (ctdb_timeout != NULL) {
- options.maxruntime = strtoul(ctdb_timeout, NULL, 0);
+ options.maxruntime = strtoul_err(ctdb_timeout, NULL, 0, &ret);
+ if (ret != 0) {
+ fprintf(stderr, "Invalid value CTDB_TIMEOUT\n");
+ exit(1);
+ }
} else {
options.maxruntime = 120;
}