Merge branch '46-add-curly-braces' into 'master'
Add curly braces using uncrustify and then reformat with clang-format back Closes #46 See merge request isc-projects/bind9!3057 (cherry picked from commit67b68e06ad)36c6105eUse coccinelle to add braces to nested single line statementd14bb713Add copy of run-clang-tidy that can fixup the filepaths056e133cUse clang-tidy to add curly braces around one-line statements
This commit is contained in:
@@ -109,12 +109,15 @@ add_name(struct dlz_example_data *state, struct record *list, const char *name,
|
||||
if (first_empty == -1 && strlen(list[i].name) == 0U) {
|
||||
first_empty = i;
|
||||
}
|
||||
if (strcasecmp(list[i].name, name) != 0)
|
||||
if (strcasecmp(list[i].name, name) != 0) {
|
||||
continue;
|
||||
if (strcasecmp(list[i].type, type) != 0)
|
||||
}
|
||||
if (strcasecmp(list[i].type, type) != 0) {
|
||||
continue;
|
||||
if (!single && strcasecmp(list[i].data, data) != 0)
|
||||
}
|
||||
if (!single && strcasecmp(list[i].data, data) != 0) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (i == MAX_RECORDS && first_empty != -1) {
|
||||
@@ -127,8 +130,9 @@ add_name(struct dlz_example_data *state, struct record *list, const char *name,
|
||||
|
||||
if (strlen(name) >= sizeof(list[i].name) ||
|
||||
strlen(type) >= sizeof(list[i].type) ||
|
||||
strlen(data) >= sizeof(list[i].data))
|
||||
strlen(data) >= sizeof(list[i].data)) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
|
||||
strncpy(list[i].name, name, sizeof(list[i].name) - 1);
|
||||
list[i].name[sizeof(list[i].name) - 1] = '\0';
|
||||
@@ -191,8 +195,9 @@ fmt_address(isc_sockaddr_t *addr, char *buffer, size_t size)
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
if (ret == NULL)
|
||||
if (ret == NULL) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
snprintf(buffer, size, "%s#%u", addr_buf, port);
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -215,14 +220,18 @@ static void
|
||||
b9_add_helper(struct dlz_example_data *state, const char *helper_name,
|
||||
void *ptr)
|
||||
{
|
||||
if (strcmp(helper_name, "log") == 0)
|
||||
if (strcmp(helper_name, "log") == 0) {
|
||||
state->log = (log_t *)ptr;
|
||||
if (strcmp(helper_name, "putrr") == 0)
|
||||
}
|
||||
if (strcmp(helper_name, "putrr") == 0) {
|
||||
state->putrr = (dns_sdlz_putrr_t *)ptr;
|
||||
if (strcmp(helper_name, "putnamedrr") == 0)
|
||||
}
|
||||
if (strcmp(helper_name, "putnamedrr") == 0) {
|
||||
state->putnamedrr = (dns_sdlz_putnamedrr_t *)ptr;
|
||||
if (strcmp(helper_name, "writeable_zone") == 0)
|
||||
}
|
||||
if (strcmp(helper_name, "writeable_zone") == 0) {
|
||||
state->writeable_zone = (dns_dlz_writeablezone_t *)ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -243,8 +252,9 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
|
||||
UNUSED(dlzname);
|
||||
|
||||
state = calloc(1, sizeof(struct dlz_example_data));
|
||||
if (state == NULL)
|
||||
if (state == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
/* Fill in the helper functions */
|
||||
va_start(ap, dbdata);
|
||||
@@ -265,23 +275,27 @@ dlz_create(const char *dlzname, unsigned int argc, char *argv[], void **dbdata,
|
||||
free(state);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
if (argv[1][strlen(argv[1]) - 1] == '.')
|
||||
if (argv[1][strlen(argv[1]) - 1] == '.') {
|
||||
strcpy(state->zone_name, argv[1]);
|
||||
else
|
||||
} else {
|
||||
sprintf(state->zone_name, "%s.", argv[1]);
|
||||
}
|
||||
|
||||
if (strcmp(state->zone_name, ".") == 0)
|
||||
if (strcmp(state->zone_name, ".") == 0) {
|
||||
extra = ".root";
|
||||
else
|
||||
} else {
|
||||
extra = ".";
|
||||
}
|
||||
|
||||
n = sprintf(soa_data, "%s hostmaster%s%s 123 900 600 86400 3600",
|
||||
state->zone_name, extra, state->zone_name);
|
||||
|
||||
if (n < 0)
|
||||
if (n < 0) {
|
||||
CHECK(ISC_R_FAILURE);
|
||||
if ((unsigned)n >= sizeof(soa_data))
|
||||
}
|
||||
if ((unsigned)n >= sizeof(soa_data)) {
|
||||
CHECK(ISC_R_NOSPACE);
|
||||
}
|
||||
|
||||
add_name(state, &state->current[0], state->zone_name, "soa", 3600,
|
||||
soa_data);
|
||||
@@ -344,35 +358,40 @@ dlz_findzonedb(void *dbdata, const char *name, dns_clientinfomethods_t *methods,
|
||||
* Returning ISC_R_NOMORE prevents the query logic from doing
|
||||
* this; it will move onto the next database after a single query.
|
||||
*/
|
||||
if (strcasecmp(name, "test.example.com") == 0)
|
||||
if (strcasecmp(name, "test.example.com") == 0) {
|
||||
return (ISC_R_NOMORE);
|
||||
}
|
||||
|
||||
/*
|
||||
* For example.net, only return ISC_R_NOMORE when queried
|
||||
* from 10.53.0.1.
|
||||
*/
|
||||
if (strcasecmp(name, "test.example.net") == 0 &&
|
||||
strncmp(addrbuf, "10.53.0.1", 9) == 0)
|
||||
strncmp(addrbuf, "10.53.0.1", 9) == 0) {
|
||||
return (ISC_R_NOMORE);
|
||||
}
|
||||
|
||||
/*
|
||||
* For bigcname.domain, return success so it appears to be
|
||||
* the zone origin; this regression tests a bug in which
|
||||
* zone origin nodes could fail to return SERVFAIL to the client.
|
||||
*/
|
||||
if (strcasecmp(name, "bigcname.domain") == 0)
|
||||
if (strcasecmp(name, "bigcname.domain") == 0) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return success if we have an exact match between the
|
||||
* zone name and the qname
|
||||
*/
|
||||
if (strcasecmp(state->zone_name, name) == 0)
|
||||
if (strcasecmp(state->zone_name, name) == 0) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
snprintf(absolute, sizeof(absolute), "%s.", name);
|
||||
if (strcasecmp(state->zone_name, absolute) == 0)
|
||||
if (strcasecmp(state->zone_name, absolute) == 0) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
@@ -471,35 +490,40 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
||||
|
||||
found = true;
|
||||
result = state->putrr(lookup, "TXT", 0, buf);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(name, "too-long") == 0 ||
|
||||
strcmp(zone, "bigcname.domain") == 0) {
|
||||
for (i = 0; i < 511; i++)
|
||||
for (i = 0; i < 511; i++) {
|
||||
buf[i] = 'x';
|
||||
}
|
||||
buf[i] = '\0';
|
||||
found = true;
|
||||
result = state->putrr(lookup, "TXT", 0, buf);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tests for DLZ redirection zones */
|
||||
if (strcmp(name, "*") == 0 && strcmp(zone, ".") == 0) {
|
||||
result = state->putrr(lookup, "A", 0, "100.100.100.2");
|
||||
found = true;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(name, "long.name.is.not.there") == 0 &&
|
||||
strcmp(zone, ".") == 0) {
|
||||
result = state->putrr(lookup, "A", 0, "100.100.100.3");
|
||||
found = true;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Answer from current records */
|
||||
@@ -509,13 +533,15 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
|
||||
result = state->putrr(lookup, state->current[i].type,
|
||||
state->current[i].ttl,
|
||||
state->current[i].data);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if (!found) {
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -572,8 +598,9 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes)
|
||||
|
||||
UNUSED(zone);
|
||||
|
||||
if (state->putnamedrr == NULL)
|
||||
if (state->putnamedrr == NULL) {
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_RECORDS; i++) {
|
||||
isc_result_t result;
|
||||
@@ -584,8 +611,9 @@ dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes)
|
||||
state->current[i].type,
|
||||
state->current[i].ttl,
|
||||
state->current[i].data);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -720,8 +748,9 @@ modrdataset(struct dlz_example_data *state, const char *name,
|
||||
char * saveptr = NULL;
|
||||
|
||||
buf = strdup(rdatastr);
|
||||
if (buf == NULL)
|
||||
if (buf == NULL) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* The format is:
|
||||
@@ -732,24 +761,29 @@ modrdataset(struct dlz_example_data *state, const char *name,
|
||||
*/
|
||||
|
||||
full_name = strtok_r(buf, "\t", &saveptr);
|
||||
if (full_name == NULL)
|
||||
if (full_name == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
ttlstr = strtok_r(NULL, "\t", &saveptr);
|
||||
if (ttlstr == NULL)
|
||||
if (ttlstr == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
dclass = strtok_r(NULL, "\t", &saveptr);
|
||||
if (dclass == NULL)
|
||||
if (dclass == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
type = strtok_r(NULL, "\t", &saveptr);
|
||||
if (type == NULL)
|
||||
if (type == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = strtok_r(NULL, "\t", &saveptr);
|
||||
if (data == NULL)
|
||||
if (data == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (name[strlen(name) - 1] != '.') {
|
||||
snprintf(absolute, sizeof(absolute), "%s.", name);
|
||||
@@ -772,8 +806,9 @@ dlz_addrdataset(const char *name, const char *rdatastr, void *dbdata,
|
||||
{
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (version != (void *)&state->transaction_started)
|
||||
if (version != (void *)&state->transaction_started) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
loginfo("dlz_example: adding rdataset %s '%s'", name, rdatastr);
|
||||
|
||||
@@ -786,8 +821,9 @@ dlz_subrdataset(const char *name, const char *rdatastr, void *dbdata,
|
||||
{
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (version != (void *)&state->transaction_started)
|
||||
if (version != (void *)&state->transaction_started) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
loginfo("dlz_example: subtracting rdataset %s '%s'", name, rdatastr);
|
||||
|
||||
@@ -799,8 +835,9 @@ dlz_delrdataset(const char *name, const char *type, void *dbdata, void *version)
|
||||
{
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
|
||||
if (version != (void *)&state->transaction_started)
|
||||
if (version != (void *)&state->transaction_started) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
loginfo("dlz_example: deleting rdataset %s of type %s", name, type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user