Skip to content

Commit eb86b95

Browse files
author
postables
committed
chore: format code
1 parent 8400ef9 commit eb86b95

26 files changed

+63
-65
lines changed

.travis.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dist: xenial
1+
dist: trusty
22
sudo: required
33
language:
44
- cpp
@@ -10,8 +10,8 @@ addons:
1010
sources:
1111
- ubuntu-toolchain-r-test
1212
packages:
13-
- gcc-10
14-
- g++-10
13+
- gcc-9
14+
- g++-9
1515
- cmake
1616

1717
before_install:
@@ -22,11 +22,11 @@ before_install:
2222

2323
script:
2424
# Link gcc-9 and g++-9 to their standard commands
25-
- sudo ln -s /usr/bin/gcc-10 /usr/local/bin/gcc
26-
- sudo ln -s /usr/bin/g++-10 /usr/local/bin/g++
25+
- sudo ln -s /usr/bin/gcc-9 /usr/local/bin/gcc
26+
- sudo ln -s /usr/bin/g++-9 /usr/local/bin/g++
2727
# Export CC and CXX to tell cmake which compiler to use
28-
- export CC=/usr/bin/gcc-10
29-
- export CXX=/usr/bin/g++-10
28+
- export CC=/usr/bin/gcc-9
29+
- export CXX=/usr/bin/g++-9
3030
# Check versions of gcc, g++ and cmake
3131
- gcc -v && g++ -v && cmake --version
3232
# build project in release mode

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
cmake_minimum_required(VERSION 3.0)
66
project(libcp2p LANGUAGES C)
7-
set(CMAKE_C_COMPILER /usr/bin/gcc-10)
7+
set(CMAKE_C_COMPILER /usr/bin/gcc)
88

99

1010
# handle debug build type

include/crypto/aes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file aes.h
2-
* @brief proivides aes encryption/decryption functions
3-
*/
2+
* @brief proivides aes encryption/decryption functions
3+
*/
44

55
#pragma once
66

include/crypto/key.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,4 @@ int libp2p_crypto_private_key_protobuf_encode(const struct PrivateKey *in,
5555
* @param peer_id the results, in a null-terminated string
5656
* @returns true(1) on success, otherwise false(0)
5757
*/
58-
int libp2p_crypto_public_key_to_peer_id(struct PublicKey *public_key,
59-
char *peer_id);
58+
int libp2p_crypto_public_key_to_peer_id(struct PublicKey *public_key, char *peer_id);

include/crypto/peerutils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file peerutils.h
2-
* @brief provides utilities for managing peer identifiers
3-
*/
2+
* @brief provides utilities for managing peer identifiers
3+
*/
44

55
#pragma once
66

include/crypto/sha1.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313

1414
/*! @file sha1.h
15-
* @brief provides sha1 hashing support
16-
*/
15+
* @brief provides sha1 hashing support
16+
*/
1717

1818
#pragma once
1919

include/crypto/sha256.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file sha256.h
2-
* @brief provides sha256 hashing support
3-
*/
2+
* @brief provides sha256 hashing support
3+
*/
44

55
#pragma once
66

include/crypto/sha512.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file sha512.h
2-
* @brief provides sha512 hashing support
3-
*/
2+
* @brief provides sha512 hashing support
3+
*/
44

55
#pragma once
66

include/encoding/base16.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file base16.h
2-
* @brief provides base 16 encoding/decoding functions
3-
*/
2+
* @brief provides base 16 encoding/decoding functions
3+
*/
44
#include <stddef.h>
55

66
/**

include/encoding/base32.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file base32.h
2-
* @brief provides base 32 encoding/decoding functions
3-
*/
2+
* @brief provides base 32 encoding/decoding functions
3+
*/
44

55
#pragma once
66

include/encoding/base64.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file base64.h
2-
* @brief provides base 64 encoding/decoding functions
3-
*/
2+
* @brief provides base 64 encoding/decoding functions
3+
*/
44

55
#pragma once
66

include/multiaddr/multiaddr.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
*/
3131

3232
/*! @struct multi_address
33-
* @typedef multi_addr_t
34-
* @brief a structure composing a multiaddress
35-
*/
33+
* @typedef multi_addr_t
34+
* @brief a structure composing a multiaddress
35+
*/
3636
typedef struct multi_address {
3737
// A multi_address represented as a string
3838
char *string;
@@ -48,7 +48,7 @@ int strpos(char *haystack, char *needle);
4848

4949
struct multi_address *
5050
multi_address_new_from_bytes(const uint8_t *byteaddress,
51-
int size); // Construct new address from bytes
51+
int size); // Construct new address from bytes
5252

5353
struct multi_address *multi_address_new_from_string(
5454
const char *straddress); // Construct new address from string
@@ -101,7 +101,8 @@ char *multi_address_get_peer_id(const struct multi_address *in);
101101
* @param b side B
102102
* @returns <0 if B > A; >0 if A > B; 0 if A == B
103103
*/
104-
int multi_address_compare(const struct multi_address *a, const struct multi_address *b);
104+
int multi_address_compare(const struct multi_address *a,
105+
const struct multi_address *b);
105106

106107
/**
107108
* @brief Check to see how these two addresses compare, ignoring IP address, only
@@ -111,4 +112,4 @@ int multi_address_compare(const struct multi_address *a, const struct multi_addr
111112
* @returns <0 if B > A; >0 if A > B; 0 if A == B
112113
*/
113114
int multi_address_compare_id(const struct multi_address *a,
114-
const struct multi_address *b);
115+
const struct multi_address *b);

include/multiaddr/protocols.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file protocols.h
2-
* @brief functions for managing multiaddr protocols
3-
*/
2+
* @brief functions for managing multiaddr protocols
3+
*/
44

55
#pragma once
66

include/multiaddr/protoutils.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file protoutils.h
2-
* @brief utility functions for working with multiaddrs and protocols
3-
*/
2+
* @brief utility functions for working with multiaddrs and protocols
3+
*/
44
#include <stddef.h>
55
#include <stdint.h>
66

@@ -60,8 +60,7 @@ int bytes_to_string(char *results, const uint8_t *bytes, int bytes_size);
6060
* @returns Failure: 1
6161
*/
6262
int address_string_to_bytes(struct Protocol *protocol, const char *incoming,
63-
size_t incoming_size, char *results,
64-
int *results_size);
63+
size_t incoming_size, char *results, int *results_size);
6564

6665
int string_to_bytes(uint8_t **finalbytes, size_t *realbbsize, const char *strx,
6766
size_t strsize);

include/multibase/multibase.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file multibase.h
2-
* @brief functions for managing multibase identifiers
3-
*/
2+
* @brief functions for managing multibase identifiers
3+
*/
44

55
#include <stdio.h>
66

@@ -30,7 +30,8 @@ int multibase_encode(const char base, const unsigned char *incoming,
3030
size_t results_max_length, size_t *results_length);
3131

3232
/***
33-
* @brief Calculates the size of the buffer neccessary to encode the incoming byte array
33+
* @brief Calculates the size of the buffer neccessary to encode the incoming byte
34+
* array
3435
* @param base the encoding to use
3536
* @param incoming the incoming array of bytes
3637
* @param incoming_length the length of the array in bytes
@@ -53,7 +54,8 @@ int multibase_decode(const unsigned char *incoming, size_t incoming_length,
5354
size_t *results_length);
5455

5556
/***
56-
* @brief Calculates the size of the buffer neccessary to decode the incoming byte array
57+
* @brief Calculates the size of the buffer neccessary to decode the incoming byte
58+
* array
5759
* @param base the encoding to use
5860
* @param incoming the incoming array of bytes
5961
* @param incoming_length the length of the array in bytes

include/multicodec/codecs.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* @author Bonedaddy
1515
* @brief macro definitions of all supported codecs
1616
* @details for actual multicodec functions see multicodec.h
17-
* @note the 0xCert-imprint-256 codec is not supported as it is an invalid variable name
17+
* @note the 0xCert-imprint-256 codec is not supported as it is an invalid variable
18+
* name
1819
*/
1920

2021
#pragma once

include/multicodec/multicodec.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ multicodec_encoded_t *multicodec_encode(char *codec, char *inData,
5959

6060
/**
6161
* @brief Decode a multicodec encoded data array
62-
* @param encoded an instance of multicodec_encoded_t holding the encoded data and codec used
62+
* @param encoded an instance of multicodec_encoded_t holding the encoded data and
63+
* codec used
6364
* @param outData the array to put the results in
6465
* @param maxOutDataLength the maximum size of the data
6566
* @returns an error code or 0 if all is well

include/multihash/errors.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file errors.h
2-
* @brief helpers for working with multihash errors
3-
*/
2+
* @brief helpers for working with multihash errors
3+
*/
44

55
#pragma once
66

include/multihash/generic.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file generic.h
2-
* @brief generic definitions for multihashes
3-
*/
2+
* @brief generic definitions for multihashes
3+
*/
44

55
#pragma once
66

include/multihash/hashes.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file hashes.h
2-
* @brief multihash definitions
3-
*/
2+
* @brief multihash definitions
3+
*/
44
#pragma once
55

66
#include "errors.h"

include/multihash/multihash.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*! @file multihash.h
2-
* @brief functions for working with multihashes
3-
*/
2+
* @brief functions for working with multihashes
3+
*/
44
#pragma once
55

66
#include <stddef.h>

src/crypto/ecdsa.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ unsigned char *libp2p_crypto_ecdsa_keypair_peerid(ecdsa_private_key_t *pk) {
9191
if (peer_id == NULL) {
9292
free(public_key);
9393
free(public_key_hash);
94-
return NULL;
94+
return NULL;
9595
}
9696
strcpy((char *)peer_id, (char *)temp_peer_id);
9797

src/multiaddr/multiaddr.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ int strpos(char *haystack, char *needle) {
2121
* Construct a new multi_address struct
2222
* @returns an empty multi_address struct
2323
*/
24-
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak" // this seems to be a false positive
2524
struct multi_address *multi_address_new() {
2625
struct multi_address *out =
2726
(struct multi_address *)malloc(sizeof(struct multi_address));
@@ -43,7 +42,7 @@ struct multi_address *multi_address_new() {
4342
*/
4443
struct multi_address *
4544
multi_address_new_from_bytes(const uint8_t *byteaddress,
46-
int size) // Construct new address from bytes
45+
int size) // Construct new address from bytes
4746
{
4847
struct multi_address *out = multi_address_new();
4948
if (out != NULL) {
@@ -344,7 +343,7 @@ int multi_address_decapsulate(struct multi_address *result, char *srci) {
344343
* @returns <0 if B > A; >0 if A > B; 0 if A == B
345344
*/
346345
int multi_address_compare(const struct multi_address *a,
347-
const struct multi_address *b) {
346+
const struct multi_address *b) {
348347
if (a == NULL && b == NULL)
349348
return 0;
350349
if (a == NULL && b != NULL)
@@ -370,7 +369,7 @@ int multi_address_compare(const struct multi_address *a,
370369
* @returns <0 if B > A; >0 if A > B; 0 if A == B
371370
*/
372371
int multi_address_compare_id(const struct multi_address *a,
373-
const struct multi_address *b) {
372+
const struct multi_address *b) {
374373
char *a_id = multi_address_get_peer_id(a);
375374
char *b_id = multi_address_get_peer_id(b);
376375
if (a_id == NULL && b_id == NULL)

src/multiaddr/protoutils.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,7 @@ int bytes_to_string(char *buffer, const uint8_t *in_bytes, int in_bytes_size) {
379379
* @returns the results array
380380
*/
381381
int address_string_to_bytes(struct Protocol *protocol, const char *incoming,
382-
size_t incoming_size, char *results,
383-
int *results_size) {
382+
size_t incoming_size, char *results, int *results_size) {
384383
static char astb__stringy[800] = "\0";
385384
memset(astb__stringy, 0, 800);
386385

@@ -533,7 +532,7 @@ int address_string_to_bytes(struct Protocol *protocol, const char *incoming,
533532
strcpy(prefixed, Num_To_HexVar_32(ilen));
534533
*results_size = ilen + 3;
535534
memset(results, 0, *results_size);
536-
strcat(results, prefixed); // 2 bytes
535+
strcat(results, prefixed); // 2 bytes
537536
strcat(results, addr_encoded); // ilen bytes + null terminator
538537
return 0;
539538
}
@@ -622,7 +621,8 @@ int string_to_bytes(uint8_t **finalbytes, size_t *realbbsize, const char *strx,
622621
} else // This is the address
623622
{
624623
memset(s_to_b, 0, 800);
625-
int rc = address_string_to_bytes(protx, wp, strlen(wp), s_to_b, &s_to_b_size);
624+
int rc =
625+
address_string_to_bytes(protx, wp, strlen(wp), s_to_b, &s_to_b_size);
626626
if (rc == 1) {
627627
malf = 1;
628628
} else {

src/network/socket_server.c

-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ void free_socket_server_config(socket_server_config_t *config) {
425425
* socket_server_config_t
426426
* @return Failure: NULL pointer
427427
*/
428-
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
429428
socket_server_config_t *new_socket_server_config(int num_addrs) {
430429
socket_server_config_t *config =
431430
calloc(sizeof(socket_server_config_t), sizeof(socket_server_config_t));

src/utils/thread_pool.c

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#pragma GCC diagnostic ignored "-Wanalyzer-double-free"
2-
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"
3-
#pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
41
/*! ********************************
52
* Author: Johan Hanssen Seferidis
63
* License: MIT

0 commit comments

Comments
 (0)