diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-09 13:46:41 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-12 01:00:00 +0100 |
commit | 459f8f201393ac458445aebbd14c45bf4d6f5912 (patch) | |
tree | 67c7eb3c6338f701cdbd3fae808b45fa126fcd74 /other | |
parent | 8339e3449f41f5d6edd16a8657f7faa84040fdc3 (diff) |
Check code formatting on Travis.
We run astyle on Travis and check if there is a diff. The build terminates if
git finds a difference.
Diffstat (limited to 'other')
-rw-r--r-- | other/bootstrap_daemon/src/command_line_arguments.h | 3 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.c | 5 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.h | 6 | ||||
-rw-r--r-- | other/fun/strkey.c | 13 | ||||
-rwxr-xr-x | other/travis/toxcore-script | 6 |
5 files changed, 21 insertions, 12 deletions
diff --git a/other/bootstrap_daemon/src/command_line_arguments.h b/other/bootstrap_daemon/src/command_line_arguments.h index c73cd15e..1d30f428 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.h +++ b/other/bootstrap_daemon/src/command_line_arguments.h | |||
@@ -37,6 +37,7 @@ | |||
37 | * @param log_backend Sets to the provided by the user log backend option. | 37 | * @param log_backend Sets to the provided by the user log backend option. |
38 | * @param run_in_foreground Sets to the provided by the user foreground option. | 38 | * @param run_in_foreground Sets to the provided by the user foreground option. |
39 | */ | 39 | */ |
40 | void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, bool *run_in_foreground); | 40 | void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend, |
41 | bool *run_in_foreground); | ||
41 | 42 | ||
42 | #endif // COMMAND_LINE_ARGUMENTS_H | 43 | #endif // COMMAND_LINE_ARGUMENTS_H |
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c index 12ae693d..29924ae4 100644 --- a/other/bootstrap_daemon/src/config.c +++ b/other/bootstrap_daemon/src/config.c | |||
@@ -143,9 +143,8 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int | |||
143 | } | 143 | } |
144 | 144 | ||
145 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, | 145 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, |
146 | int *enable_ipv6, | 146 | int *enable_ipv6, int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, |
147 | int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, uint16_t **tcp_relay_ports, | 147 | uint16_t **tcp_relay_ports, int *tcp_relay_port_count, int *enable_motd, char **motd) |
148 | int *tcp_relay_port_count, int *enable_motd, char **motd) | ||
149 | { | 148 | { |
150 | config_t cfg; | 149 | config_t cfg; |
151 | 150 | ||
diff --git a/other/bootstrap_daemon/src/config.h b/other/bootstrap_daemon/src/config.h index 13cf929a..93e7fc49 100644 --- a/other/bootstrap_daemon/src/config.h +++ b/other/bootstrap_daemon/src/config.h | |||
@@ -37,9 +37,9 @@ | |||
37 | * @return 1 on success, | 37 | * @return 1 on success, |
38 | * 0 on failure, doesn't modify any data pointed by arguments. | 38 | * 0 on failure, doesn't modify any data pointed by arguments. |
39 | */ | 39 | */ |
40 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, int *enable_ipv6, | 40 | int get_general_config(const char *cfg_file_path, char **pid_file_path, char **keys_file_path, int *port, |
41 | int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, uint16_t **tcp_relay_ports, | 41 | int *enable_ipv6, int *enable_ipv4_fallback, int *enable_lan_discovery, int *enable_tcp_relay, |
42 | int *tcp_relay_port_count, int *enable_motd, char **motd); | 42 | uint16_t **tcp_relay_ports, int *tcp_relay_port_count, int *enable_motd, char **motd); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Bootstraps off nodes listed in the config file. | 45 | * Bootstraps off nodes listed in the config file. |
diff --git a/other/fun/strkey.c b/other/fun/strkey.c index 7e5a1e1c..649b26dd 100644 --- a/other/fun/strkey.c +++ b/other/fun/strkey.c | |||
@@ -46,6 +46,7 @@ | |||
46 | void print_key(unsigned char *key) | 46 | void print_key(unsigned char *key) |
47 | { | 47 | { |
48 | size_t i; | 48 | size_t i; |
49 | |||
49 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) { | 50 | for (i = 0; i < crypto_box_PUBLICKEYBYTES; i++) { |
50 | if (key[i] < 16) { | 51 | if (key[i] < 16) { |
51 | fprintf(stdout, "0"); | 52 | fprintf(stdout, "0"); |
@@ -67,11 +68,14 @@ int main(int argc, char *argv[]) | |||
67 | offset = atoi(argv[1]); | 68 | offset = atoi(argv[1]); |
68 | char *desired_hex = argv[2]; | 69 | char *desired_hex = argv[2]; |
69 | len = strlen(desired_hex); | 70 | len = strlen(desired_hex); |
71 | |||
70 | if (len % 2 != 0) { | 72 | if (len % 2 != 0) { |
71 | fprintf(stderr, "Desired key should have an even number of letters\n"); | 73 | fprintf(stderr, "Desired key should have an even number of letters\n"); |
72 | exit(1); | 74 | exit(1); |
73 | } | 75 | } |
74 | size_t block_length = (offset < 0 ? 0 : offset) + len/2; | 76 | |
77 | size_t block_length = (offset < 0 ? 0 : offset) + len / 2; | ||
78 | |||
75 | if (block_length > crypto_box_PUBLICKEYBYTES) { | 79 | if (block_length > crypto_box_PUBLICKEYBYTES) { |
76 | fprintf(stderr, "The given key with the given offset exceed public key's length\n"); | 80 | fprintf(stderr, "The given key with the given offset exceed public key's length\n"); |
77 | exit(1); | 81 | exit(1); |
@@ -80,6 +84,7 @@ int main(int argc, char *argv[]) | |||
80 | // convert hex to bin | 84 | // convert hex to bin |
81 | char *pos = desired_hex; | 85 | char *pos = desired_hex; |
82 | size_t i; | 86 | size_t i; |
87 | |||
83 | for (i = 0; i < len; pos += 2) { | 88 | for (i = 0; i < len; pos += 2) { |
84 | sscanf(pos, "%2hhx", &desired_bin[i]); | 89 | sscanf(pos, "%2hhx", &desired_bin[i]); |
85 | ++i; | 90 | ++i; |
@@ -97,12 +102,14 @@ int main(int argc, char *argv[]) | |||
97 | 102 | ||
98 | if (offset < 0) { | 103 | if (offset < 0) { |
99 | int found = 0; | 104 | int found = 0; |
105 | |||
100 | do { | 106 | do { |
101 | #ifdef PRINT_TRIES_COUNT | 107 | #ifdef PRINT_TRIES_COUNT |
102 | tries ++; | 108 | tries ++; |
103 | #endif | 109 | #endif |
104 | crypto_box_keypair(public_key, secret_key); | 110 | crypto_box_keypair(public_key, secret_key); |
105 | int i; | 111 | int i; |
112 | |||
106 | for (i = 0; i <= crypto_box_PUBLICKEYBYTES - len; i ++) { | 113 | for (i = 0; i <= crypto_box_PUBLICKEYBYTES - len; i ++) { |
107 | if (memcmp(public_key + i, desired_bin, len) == 0) { | 114 | if (memcmp(public_key + i, desired_bin, len) == 0) { |
108 | found = 1; | 115 | found = 1; |
@@ -115,7 +122,7 @@ int main(int argc, char *argv[]) | |||
115 | 122 | ||
116 | do { | 123 | do { |
117 | #ifdef PRINT_TRIES_COUNT | 124 | #ifdef PRINT_TRIES_COUNT |
118 | tries ++; | 125 | tries ++; |
119 | #endif | 126 | #endif |
120 | crypto_box_keypair(public_key, secret_key); | 127 | crypto_box_keypair(public_key, secret_key); |
121 | } while (memcmp(p, desired_bin, len) != 0); | 128 | } while (memcmp(p, desired_bin, len) != 0); |
@@ -130,7 +137,7 @@ int main(int argc, char *argv[]) | |||
130 | fprintf(stdout, "\n"); | 137 | fprintf(stdout, "\n"); |
131 | 138 | ||
132 | #ifdef PRINT_TRIES_COUNT | 139 | #ifdef PRINT_TRIES_COUNT |
133 | fprintf(stdout, "Found the key pair on %llu try.\n", tries); | 140 | fprintf(stdout, "Found the key pair on %llu try.\n", tries); |
134 | #endif | 141 | #endif |
135 | 142 | ||
136 | return 0; | 143 | return 0; |
diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index b2ee5d02..b99bbe5b 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script | |||
@@ -3,8 +3,10 @@ | |||
3 | set -e -x | 3 | set -e -x |
4 | 4 | ||
5 | # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. | 5 | # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. |
6 | ../apidsl/_build/apigen.native ./other/apidsl/tox.in.h | $ASTYLE --options=./other/astyle/astylerc > toxcore/tox.h | 6 | ../apidsl/_build/apigen.native other/apidsl/tox.in.h | $ASTYLE --options=other/astyle/astylerc > toxcore/tox.h |
7 | ../apidsl/_build/apigen.native ./other/apidsl/toxav.in.h | $ASTYLE --options=./other/astyle/astylerc > toxav/toxav.h | 7 | ../apidsl/_build/apigen.native other/apidsl/toxav.in.h | $ASTYLE --options=other/astyle/astylerc > toxav/toxav.h |
8 | # Check if the code is formatted according to the astyle configuration. | ||
9 | $ASTYLE --options=other/astyle/astylerc `find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"` | ||
8 | git diff --exit-code | 10 | git diff --exit-code |
9 | 11 | ||
10 | # Build toxcore and run tests. | 12 | # Build toxcore and run tests. |