mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #21676 from keszybz/rename-variables-to-make-codeql-happy
Rename variables to make codeql happy
This commit is contained in:
@@ -146,7 +146,6 @@ static int test_options_cb(uint8_t code, uint8_t len, const void *option, void *
|
||||
int *desclen = NULL, *descpos = NULL;
|
||||
uint8_t optcode = 0;
|
||||
uint8_t optlen = 0;
|
||||
uint8_t i;
|
||||
|
||||
assert_se((!desc && !code && !len) || desc);
|
||||
|
||||
@@ -199,11 +198,11 @@ static int test_options_cb(uint8_t code, uint8_t len, const void *option, void *
|
||||
assert_se(code == optcode);
|
||||
assert_se(len == optlen);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
|
||||
for (unsigned i = 0; i < len; i++) {
|
||||
if (verbose)
|
||||
printf("0x%02x(0x%02x) ", ((uint8_t*) option)[i],
|
||||
descoption[*descpos + 2 + i]);
|
||||
printf("0x%02x(0x%02x) ",
|
||||
((uint8_t*) option)[i],
|
||||
descoption[*descpos + 2 + i]);
|
||||
|
||||
assert_se(((uint8_t*) option)[i] == descoption[*descpos + 2 + i]);
|
||||
}
|
||||
@@ -278,7 +277,7 @@ static void test_option_removal(struct option_desc *desc) {
|
||||
assert_se(dhcp_option_parse(message, sizeof(DHCPMessage) + desc->len, NULL, NULL, NULL) < 0);
|
||||
}
|
||||
|
||||
static uint8_t options[64] = {
|
||||
static uint8_t the_options[64] = {
|
||||
'A', 'B', 'C', 'D',
|
||||
160, 2, 0x11, 0x12,
|
||||
0,
|
||||
@@ -292,7 +291,6 @@ static uint8_t options[64] = {
|
||||
static void test_option_set(void) {
|
||||
_cleanup_free_ DHCPMessage *result = NULL;
|
||||
size_t offset = 0, len, pos;
|
||||
unsigned i;
|
||||
|
||||
result = malloc0(sizeof(DHCPMessage) + 11);
|
||||
assert_se(result);
|
||||
@@ -316,26 +314,26 @@ static void test_option_set(void) {
|
||||
|
||||
offset = pos = 4;
|
||||
len = 11;
|
||||
while (pos < len && options[pos] != SD_DHCP_OPTION_END) {
|
||||
while (pos < len && the_options[pos] != SD_DHCP_OPTION_END) {
|
||||
assert_se(dhcp_option_append(result, len, &offset, DHCP_OVERLOAD_SNAME,
|
||||
options[pos],
|
||||
options[pos + 1],
|
||||
&options[pos + 2]) >= 0);
|
||||
the_options[pos],
|
||||
the_options[pos + 1],
|
||||
&the_options[pos + 2]) >= 0);
|
||||
|
||||
if (options[pos] == SD_DHCP_OPTION_PAD)
|
||||
if (the_options[pos] == SD_DHCP_OPTION_PAD)
|
||||
pos++;
|
||||
else
|
||||
pos += 2 + options[pos + 1];
|
||||
pos += 2 + the_options[pos + 1];
|
||||
|
||||
if (pos < len)
|
||||
assert_se(offset == pos);
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
for (unsigned i = 0; i < 9; i++) {
|
||||
if (verbose)
|
||||
printf("%2u: 0x%02x(0x%02x) (options)\n", i, result->options[i],
|
||||
options[i]);
|
||||
assert_se(result->options[i] == options[i]);
|
||||
the_options[i]);
|
||||
assert_se(result->options[i] == the_options[i]);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
@@ -350,11 +348,11 @@ static void test_option_set(void) {
|
||||
|
||||
assert_se(result->options[10] == SD_DHCP_OPTION_PAD);
|
||||
|
||||
for (i = 0; i < pos - 8; i++) {
|
||||
for (unsigned i = 0; i < pos - 8; i++) {
|
||||
if (verbose)
|
||||
printf("%2u: 0x%02x(0x%02x) (sname)\n", i, result->sname[i],
|
||||
options[i + 9]);
|
||||
assert_se(result->sname[i] == options[i + 9]);
|
||||
the_options[i + 9]);
|
||||
assert_se(result->sname[i] == the_options[i + 9]);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
@@ -362,19 +360,17 @@ static void test_option_set(void) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
unsigned i;
|
||||
|
||||
test_invalid_buffer_length();
|
||||
test_message_init();
|
||||
|
||||
test_options(NULL);
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(option_tests); i++)
|
||||
for (unsigned i = 0; i < ELEMENTSOF(option_tests); i++)
|
||||
test_options(&option_tests[i]);
|
||||
|
||||
test_option_set();
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(option_tests); i++) {
|
||||
for (unsigned i = 0; i < ELEMENTSOF(option_tests); i++) {
|
||||
struct option_desc *desc = &option_tests[i];
|
||||
if (!desc->success || desc->snamelen > 0 || desc->filelen > 0)
|
||||
continue;
|
||||
|
||||
@@ -236,7 +236,7 @@ static int gather_stdout_three(int fd, void *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const gather_stdout_callback_t gather_stdout[] = {
|
||||
const gather_stdout_callback_t gather_stdouts[] = {
|
||||
gather_stdout_one,
|
||||
gather_stdout_two,
|
||||
gather_stdout_three,
|
||||
@@ -277,7 +277,8 @@ TEST(stdout_gathering) {
|
||||
if (access(name, X_OK) < 0 && ERRNO_IS_PRIVILEGE(errno))
|
||||
return;
|
||||
|
||||
r = execute_directories(dirs, DEFAULT_TIMEOUT_USEC, gather_stdout, args, NULL, NULL, EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS);
|
||||
r = execute_directories(dirs, DEFAULT_TIMEOUT_USEC, gather_stdouts, args, NULL, NULL,
|
||||
EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS);
|
||||
assert_se(r >= 0);
|
||||
|
||||
log_info("got: %s", output);
|
||||
|
||||
Reference in New Issue
Block a user