if (dest_size > dest_len) { \
sstrncpy((dest) + dest_len, (src), dest_size - dest_len); \
} \
- (dest)[dest_size - 1] = 0; \
+ (dest)[dest_size - 1] = '\0'; \
} while (0)
static int ceph_cb_number(void *ctx, const char *number_val,
}
memmove(state->key, key, sz - 1);
- state->key[sz - 1] = 0;
+ state->key[sz - 1] = '\0';
return CEPH_CB_CONTINUE;
}
/* Strip colon off the first column, if found */
if (key[key_len - 1] == ':')
- key[key_len - 1] = 0;
+ key[key_len - 1] = '\0';
status = parse_value(fields[1], &value, DS_TYPE_DERIVE);
if (status != 0)
int status;
snprintf(ident_str, sizeof(ident_str), "%s/%s", hostname_g, value_string_g);
- ident_str[sizeof(ident_str) - 1] = 0;
+ ident_str[sizeof(ident_str) - 1] = '\0';
status = lcc_string_to_identifier(connection, &ident, ident_str);
if (status != 0) {
}
snprintf(address, sizeof(address), "unix:%s", socket_file_g);
- address[sizeof(address) - 1] = 0;
+ address[sizeof(address) - 1] = '\0';
connection = NULL;
status = lcc_connect(address, &connection);
strncpy(vl->identifier.type,
(vl->values_types[0] == LCC_TYPE_GAUGE) ? "gauge" : "derive",
sizeof(vl->identifier.type));
- vl->identifier.type[sizeof(vl->identifier.type) - 1] = 0;
+ vl->identifier.type[sizeof(vl->identifier.type) - 1] = '\0';
snprintf(vl->identifier.type_instance, sizeof(vl->identifier.type_instance),
"ti%li", random());
/* Create a null-terminated version of the string. */
char buffer[number_len + 1];
memcpy(buffer, number, number_len);
- buffer[sizeof(buffer) - 1] = 0;
+ buffer[sizeof(buffer) - 1] = '\0';
if (db->state[db->depth].entry == NULL ||
db->state[db->depth].entry->type != KEY) {
char name[in_name_len + 1];
memmove(name, in_name, in_name_len);
- name[sizeof(name) - 1] = 0;
+ name[sizeof(name) - 1] = '\0';
if (cj_load_key(ctx, name) != 0)
return CJ_CB_ABORT;
/* Move everything after the position one position to the left.
* Add a null-byte as last character in the buffer. */
memmove(buf + i + 1, buf + i + 2, buf_len - i - 2);
- buf[buf_len - 1] = 0;
+ buf[buf_len - 1] = '\0';
}
return 0;
} /* int strunescape */
value_len = strlen(value);
while ((value_len > 0) && isspace((int)value[value_len - 1])) {
- value[value_len - 1] = 0;
+ value[value_len - 1] = '\0';
value_len--;
}
} /* }}} int cf_util_get_string */
/* Assures the config option is a string and copies it to the provided buffer.
- * Assures null-termination. */
+ * Assures NUL-termination. */
int cf_util_get_string_buffer(const oconfig_item_t *ci, char *buffer, /* {{{ */
size_t buffer_size) {
if ((ci == NULL) || (buffer == NULL) || (buffer_size < 1))
}
strncpy(buffer, ci->values[0].value.string, buffer_size);
- buffer[buffer_size - 1] = 0;
+ buffer[buffer_size - 1] = '\0';
return 0;
} /* }}} int cf_util_get_string_buffer */
if (errbuf[0] == 0) {
snprintf(errbuf, sizeof(errbuf), "Unknown error %#x", status);
}
- errbuf[sizeof(errbuf) - 1] = 0;
+ errbuf[sizeof(errbuf) - 1] = '\0';
ERROR("ipmi plugin: %s failed for `%s`: %s", func, st->name, errbuf);
} /* void c_ipmi_error */
return;
ipmi_sensor_get_name(sensor, temp, sizeof(temp));
- temp[sizeof(temp) - 1] = 0;
+ temp[sizeof(temp) - 1] = '\0';
if (entity_id_string != NULL && strlen(temp))
snprintf(sensor_name, sizeof(sensor_name), "%s %s", temp, entity_id_string);
if (irq_name_len == 4 && (strncmp(irq_name, "FIQ:", 4) == 0))
continue;
- irq_name[irq_name_len - 1] = 0;
+ irq_name[irq_name_len - 1] = '\0';
irq_name_len--;
irq_value = 0;
* is very useful to add formatted stuff to the end of a buffer. */
#define SSTRCPY(d, s) \
do { \
- strncpy((d), (s), sizeof(d)); \
- (d)[sizeof(d) - 1] = 0; \
+ strncpy((d), (s), sizeof(d) - 1); \
+ (d)[sizeof(d) - 1] = '\0'; \
} while (0)
#define SSTRCAT(d, s) \
do { \
size_t _l = strlen(d); \
strncpy((d) + _l, (s), sizeof(d) - _l); \
- (d)[sizeof(d) - 1] = 0; \
+ (d)[sizeof(d) - 1] = '\0'; \
} while (0)
#define SSTRCATF(d, ...) \
do { \
char _b[sizeof(d)]; \
snprintf(_b, sizeof(_b), __VA_ARGS__); \
- _b[sizeof(_b) - 1] = 0; \
+ _b[sizeof(_b) - 1] = '\0'; \
SSTRCAT((d), _b); \
} while (0)
}
#endif /* STRERROR_R_CHAR_P */
- buf[buflen - 1] = 0;
+ buf[buflen - 1] = '\0';
return buf;
} /* char *sstrerror */
return -1;
sstrerror(err, c->errbuf, sizeof(c->errbuf));
- c->errbuf[sizeof(c->errbuf) - 1] = 0;
+ c->errbuf[sizeof(c->errbuf) - 1] = '\0';
return 0;
} /* }}} int lcc_set_errno */
while (str_len > 0) {
if (str[str_len - 1] >= 32)
break;
- str[str_len - 1] = 0;
+ str[str_len - 1] = '\0';
str_len--;
}
} /* }}} void lcc_chomp */
/* Now copy the message. */
strncpy(res.message, ptr, sizeof(res.message));
- res.message[sizeof(res.message) - 1] = 0;
+ res.message[sizeof(res.message) - 1] = '\0';
/* Error or no lines follow: We're done. */
if (res.status <= 0) {
snprintf(command, sizeof(command), "GETVAL %s",
lcc_strescape(ident_esc, ident_str, sizeof(ident_esc)));
- command[sizeof(command) - 1] = 0;
+ command[sizeof(command) - 1] = '\0';
/* Send talk to the daemon.. */
status = lcc_sendreceive(c, command, &res);
ident->type_instance);
}
- string[string_size - 1] = 0;
+ string[string_size - 1] = '\0';
return 0;
} /* }}} int lcc_identifier_to_string */
if (status != 0) {
char errmsg[1024];
regerror(status, &re->re, errmsg, sizeof(errmsg));
- errmsg[sizeof(errmsg) - 1] = 0;
+ errmsg[sizeof(errmsg) - 1] = '\0';
log_err("Compiling regex `%s' for `%s' failed: %s.", re->re_str, option,
errmsg);
sfree(re->re_str);
char err[256] = {0};
if (!na_startup(err, sizeof(err))) {
- err[sizeof(err) - 1] = 0;
+ err[sizeof(err) - 1] = '\0';
ERROR("netapp plugin: Error initializing netapp API: %s", err);
return 1;
}
#if COLLECT_DEBUG
char name[6 * DATA_MAX_NAME_LEN];
FORMAT_VL(name, sizeof(name), vl);
- name[sizeof(name) - 1] = 0;
+ name[sizeof(name) - 1] = '\0';
DEBUG("network plugin: network_dispatch_values: "
"NOT dispatching %s.",
name);
#if COLLECT_DEBUG
char name[6 * DATA_MAX_NAME_LEN];
FORMAT_VL(name, sizeof(name), vl);
- name[sizeof(name) - 1] = 0;
+ name[sizeof(name) - 1] = '\0';
DEBUG("network plugin: network_write: "
"NOT sending %s.",
name);
snprintf(file, sizeof(file), "%s/%s", path,
family_info->features[i].filename);
- file[sizeof(file) - 1] = 0;
+ file[sizeof(file) - 1] = '\0';
buffer = NULL;
buffer_size = 0;
status = OCIErrorGet(eh, (ub4)record_number,
/* sqlstate = */ NULL, &error_code, (text *)&buffer[0],
(ub4)sizeof(buffer), OCI_HTYPE_ERROR);
- buffer[sizeof(buffer) - 1] = 0;
+ buffer[sizeof(buffer) - 1] = '\0';
if (status == OCI_NO_DATA)
return;
}
memcpy(buffer, temp, buffer_size - 1);
- buffer[buffer_size - 1] = 0;
+ buffer[buffer_size - 1] = '\0';
*ret_buffer = buffer;
return 0;
return NULL;
}
- info.pr_psargs[sizeof(info.pr_psargs) - 1] = 0;
sstrncpy(buffer, info.pr_psargs, buffer_size);
return buffer;
continue;
if (cpy[strlen(cpy) - 1] == '\n')
- cpy[strlen(cpy) - 1] = 0;
+ cpy[strlen(cpy) - 1] = '\0';
Py_BEGIN_ALLOW_THREADS;
ERROR("%s", cpy);
snprintf(key, sizeof(key), "%s.rrd", identifier);
else
snprintf(key, sizeof(key), "%s/%s.rrd", datadir, identifier);
- key[sizeof(key) - 1] = 0;
+ key[sizeof(key) - 1] = '\0';
status = c_avl_get(cache, key, (void *)&rc);
if (status != 0) {
continue;
if (fields[0][len - 1] != ':')
continue;
- fields[0][len - 1] = 0;
+ fields[0][len - 1] = '\0';
for (int i = 1; i < numfields; i++) {
len = strlen(fields[i]);
if (((size_t)status) >= buffer_free) /* truncated */
{
- dst[dst_size - 1] = 0;
+ dst[dst_size - 1] = '\0';
return ENOMEM;
} else /* if (status < buffer_free) */
{
dst[i] = src[i];
}
dst[num_chars] = 0;
- dst[dst_size - 1] = 0;
+ dst[dst_size - 1] = '\0';
if (dst_size <= vb->val_len)
return ENOMEM;
while (buffer_size > 0) {
if ((buffer[buffer_size - 1] == '\n') ||
(buffer[buffer_size - 1] == '\r')) {
- buffer[buffer_size - 1] = 0;
+ buffer[buffer_size - 1] = '\0';
buffer_size--;
} else {
break;
config_host ? config_host : DEFAULT_HOST,
config_port ? config_port : DEFAULT_PORT);
}
- buffer[sizeof(buffer) - 1] = 0;
+ buffer[sizeof(buffer) - 1] = '\0';
if (memcmp("[TS]\r\n", buffer, 6) != 0) {
ERROR("teamspeak2 plugin: Unexpected response when connecting "
return -1;
}
- buffer[buffer_size - 1] = 0;
+ buffer[buffer_size - 1] = '\0';
return 0;
} /* int tss2_receive_line */
ERROR("teamspeak2 plugin: tss2_receive_line failed.");
return -1;
}
- response[sizeof(response) - 1] = 0;
+ response[sizeof(response) - 1] = '\0';
/* Check answer */
if ((strncasecmp("OK", response, 2) == 0) &&
ERROR("teamspeak2 plugin: tss2_receive_line failed.");
return -1;
}
- buffer[sizeof(buffer) - 1] = 0;
+ buffer[sizeof(buffer) - 1] = '\0';
if (strncmp("average_packet_loss=", buffer,
strlen("average_packet_loss=")) == 0) {
status);
return status;
}
- tmp[sizeof(tmp) - 1] = 0;
+ tmp[sizeof(tmp) - 1] = '\0';
snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s",
r->instance_prefix, tmp);
}
}
- vl.type_instance[sizeof(vl.type_instance) - 1] = 0;
+ vl.type_instance[sizeof(vl.type_instance) - 1] = '\0';
/* }}} */
/* Annotate meta data. {{{ */
char *key_copy;
char *value_copy;
- buffer[sizeof(buffer) - 1] = 0;
+ buffer[sizeof(buffer) - 1] = '\0';
len = strlen(buffer);
/* Remove trailing newline characters. */
#define BUFFER_ADD(c) \
do { \
if (dst_pos >= (buffer_size - 1)) { \
- buffer[buffer_size - 1] = 0; \
+ buffer[buffer_size - 1] = '\0'; \
return -ENOMEM; \
} \
buffer[dst_pos] = (c); \
#define BUFFER_ADD(c) \
do { \
if (dst_pos >= (buffer_size - 1)) { \
- buffer[buffer_size - 1] = 0; \
+ buffer[buffer_size - 1] = '\0'; \
return -ENOMEM; \
} \
buffer[dst_pos] = (c); \
return ENOMEM;
/* trim trailing slash */
- copy[strlen(copy) - 1] = 0;
+ copy[strlen(copy) - 1] = '\0';
status = ignorelist_append_regex(il, copy);
sfree(copy);
* be fine and we can return. */
clearerr(obj->fh);
if (fgets(buf, buflen, obj->fh) != NULL) {
- buf[buflen - 1] = 0;
+ buf[buflen - 1] = '\0';
return 0;
}
/* If we get here: file was re-opened and there may be more to read.. Let's
* try again. */
if (fgets(buf, buflen, obj->fh) != NULL) {
- buf[buflen - 1] = 0;
+ buf[buflen - 1] = '\0';
return 0;
}