CLEANUP: 51d: Aligned if statements with HAProxy best practices and removed casts from malloc.

Changes to if statements do not affect code operation, just layout of
the code. Type casts from malloc returns have been removed as this cast
happens automatically from the void* type.

This may be backported to 1.6.
This commit is contained in:
ben@51degrees.com 2016-01-08 13:52:32 +00:00 committed by Willy Tarreau
parent 496299a4d5
commit d3842523ff
1 changed files with 7 additions and 9 deletions

View File

@ -329,9 +329,9 @@ static void _51d_process_match(const struct arg *args, struct sample *smp)
}
}
#endif
if (!found) {
if (!found)
chunk_appendf(temp, "%s", no_data);
}
/* Add separator. */
chunk_appendf(temp, "%c", global._51degrees.property_separator);
++i;
@ -408,9 +408,8 @@ static int _51d_fetch(const struct arg *args, struct sample *smp, const char *kw
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
fiftyoneDegreesWorksetPoolRelease(global._51degrees.pool, ws);
if (lru) {
if (lru)
_51d_insert_cache_entry(smp, lru, (void*)args);
}
#endif
return 1;
@ -465,9 +464,8 @@ static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
fiftyoneDegreesWorksetPoolRelease(global._51degrees.pool, ws);
if (lru) {
if (lru)
_51d_insert_cache_entry(smp, lru, (void*)args);
}
#endif
return 1;
@ -480,7 +478,7 @@ void _51d_init_http_headers()
const fiftyoneDegreesAsciiString *headerName;
fiftyoneDegreesDataSet *ds = &global._51degrees.data_set;
global._51degrees.header_count = ds->httpHeadersCount;
global._51degrees.header_names = (struct chunk*)malloc(global._51degrees.header_count * sizeof(struct chunk));
global._51degrees.header_names = malloc(global._51degrees.header_count * sizeof(struct chunk));
for (index = 0; index < global._51degrees.header_count; index++) {
headerName = fiftyoneDegreesGetString(ds, ds->httpHeaders[index].headerNameOffset);
(global._51degrees.header_names + index)->str = (char*)&headerName->firstByte;
@ -497,8 +495,8 @@ void _51d_init_http_headers()
global._51degrees.header_count = fiftyoneDegreesGetHttpHeaderCount();
global._51degrees.device_offsets.firstOffset = (fiftyoneDegreesDeviceOffset*)malloc(
global._51degrees.header_count * sizeof(fiftyoneDegreesDeviceOffset));
global._51degrees.header_names = (struct chunk*)malloc(global._51degrees.header_count * sizeof(struct chunk));
global._51degrees.header_offsets = (int32_t*)malloc(global._51degrees.header_count * sizeof(int32_t));
global._51degrees.header_names = malloc(global._51degrees.header_count * sizeof(struct chunk));
global._51degrees.header_offsets = malloc(global._51degrees.header_count * sizeof(int32_t));
for (index = 0; index < global._51degrees.header_count; index++) {
global._51degrees.header_offsets[index] = fiftyoneDegreesGetHttpHeaderNameOffset(index);
global._51degrees.header_names[index].str = (char*)fiftyoneDegreesGetHttpHeaderNamePointer(index);