Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] clang-format the include order + fix resulting build breaks #606

Merged
merged 1 commit into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/include/aes_gcm_dev.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#include <squareup/subzero/internal.pb.h>
#include <stddef.h>
#include <stdint.h>

/* This header is meant for the dev target, and should only be included in the
* dev implementation */

Expand Down
5 changes: 5 additions & 0 deletions core/include/aes_gcm_ncipher.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#pragma once

#include <nfastapp.h>
#include <squareup/subzero/internal.pb.h>
#include <stddef.h>
#include <stdint.h>

/* This header is meant for the nCipher target, and should only be included in the
* codesafe/ncipher implementation */

Expand Down
3 changes: 3 additions & 0 deletions core/include/print.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include <stddef.h>
#include <stdint.h>

void print_uint8(uint8_t value);
void print_uint16(uint16_t value);
void print_uint32(uint32_t value);
Expand Down
3 changes: 3 additions & 0 deletions core/include/qrsignatures.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/**
* signature verification wrapper for trezor crypto util.
Expand Down
2 changes: 2 additions & 0 deletions core/include/sign.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <squareup/subzero/internal.pb.h>

Result handle_sign_tx(
const InternalCommandRequest_SignTxRequest* const request,
InternalCommandResponse_SignTxResponse *response);
Expand Down
12 changes: 6 additions & 6 deletions core/src/checks/bip32.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <stdio.h>
#include <string.h>

#include "bip32.h"
#include "bip39.h"
#include "curves.h"

#include "config.h"
#include "bip39.h"
#include "checks.h"
#include "config.h"
#include "curves.h"
#include "log.h"
#include "squareup/subzero/internal.pb.h"

#include <stdio.h>
#include <string.h>

/**
* Perform BIP32 derivation using a hardcoded mnemonic and verify that we get
* specific private/public keys back.
Expand Down
31 changes: 14 additions & 17 deletions core/src/checks/check_sign_tx.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
#include "base58.h"
#include "bip32.h"
#include "bip39.h"
#include "checks.h"
#include "conv.h"
#include "curves.h"
#include "ecdsa.h"
#include "hash.h"
#include "log.h"
#include "memzero.h"
#include "nist256p1.h"
#include "print.h"
#include "qrsignatures.h"
#include "script.h"
#include "sign.h"

#include <assert.h>
#include <config.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include <protection.h>
#include <rpc.h>
#include <pb_encode.h>
#include <pb_decode.h>
#include <squareup/subzero/common.pb.h>
#include <squareup/subzero/internal.pb.h>
#include <squareup/subzero/service.pb.h>
#include <stdio.h>
#include <string.h>

#include <assert.h>

#include "checks.h"
#include "conv.h"
#include "hash.h"
#include "log.h"
#include "print.h"
#include "script.h"
#include "sign.h"
#include "ecdsa.h"
#include "nist256p1.h"
#include "memzero.h"
#include "qrsignatures.h"


// Return a constructed request for test
static int construct_request(InternalCommandRequest_SignTxRequest *tx) {

Expand Down
6 changes: 3 additions & 3 deletions core/src/checks/conv_checks.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <inttypes.h>
#include <stdint.h>

#include "checks.h"
#include "conv.h"
#include "log.h"

#include <inttypes.h>
#include <stdint.h>

int verify_conv_btc_to_satoshi(void) {
uint32_t btc = 0;
uint64_t satoshi = conv_btc_to_satoshi(btc);
Expand Down
6 changes: 3 additions & 3 deletions core/src/checks/self_checks.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdio.h>
#include <stdlib.h>

#include "checks.h"
#include "log.h"

#include <stdio.h>
#include <stdlib.h>

typedef int (*self_check_function)(void);

typedef struct self_check_function_info {
Expand Down
6 changes: 3 additions & 3 deletions core/src/checks/validate_fees.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <stdio.h>

#include "checks.h"
#include "log.h"
#include "rpc.h"
#include "sign.h"
#include "squareup/subzero/internal.pb.h"
#include "log.h"

#include <stdio.h>

int verify_validate_fees(void) {
int r = 0;
Expand Down
9 changes: 5 additions & 4 deletions core/src/dev/aes_gcm.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <stdint.h>
#include <squareup/subzero/internal.pb.h> // For error codes
#include "log.h"
#include "memzero.h"
#include "aes_gcm_dev.h"
#include "gcm.h"
#include "log.h"
#include "memzero.h"
#include "rand.h"

#include <squareup/subzero/internal.pb.h> // For error codes
#include <stdint.h>

#define IV_SIZE_IN_BYTES (12)
#define TAG_SIZE_IN_BYTES (16)

Expand Down
4 changes: 2 additions & 2 deletions core/src/dev/execute_command_hooks.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <squareup/subzero/internal.pb.h>

#include "rpc.h"

#include <squareup/subzero/internal.pb.h>

Result pre_execute_command(const InternalCommandRequest* const in) {
(void)in;
return Result_SUCCESS;
Expand Down
15 changes: 8 additions & 7 deletions core/src/dev/init_wallet.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#include <assert.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include <squareup/subzero/common.pb.h>
#include <squareup/subzero/internal.pb.h>
#include <stdio.h>
#include "init_wallet.h"

#include "bip32.h"
#include "bip39.h"
#include "checks.h"
#include "config.h"
#include "curves.h"
#include "init_wallet.h"
#include "log.h"
#include "protection.h"
#include "rand.h"
#include "rpc.h"

#include <assert.h>
#include <pb_decode.h>
#include <pb_encode.h>
#include <squareup/subzero/common.pb.h>
#include <squareup/subzero/internal.pb.h>
#include <stdio.h>

/**
* Initialize a wallet.
* in prod:
Expand Down
9 changes: 5 additions & 4 deletions core/src/dev/no_rollback.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "no_rollback.h"

#include "config.h"
#include "log.h"

#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#include "no_rollback.h"
#include "config.h"
#include "log.h"

Result no_rollback_read(const char* filename, char buf[static VERSION_SIZE]) {
char tmp_file[100];
snprintf(tmp_file, sizeof(tmp_file), "/tmp/%s", filename);
Expand Down
11 changes: 6 additions & 5 deletions core/src/dev/protection.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <assert.h>
#include <protection.h>
#include <squareup/subzero/common.pb.h>
#include <squareup/subzero/internal.pb.h>
#include "protection.h"

#include "aes_gcm_dev.h"
#include "log.h"
#include "memzero.h"
#include "aes_gcm_dev.h"
#include "rand.h"

#include <assert.h>
#include <squareup/subzero/common.pb.h>
#include <squareup/subzero/internal.pb.h>

// Protection: developer edition.

// Hardcoded master seed encryption key and public key encryption key
Expand Down
10 changes: 5 additions & 5 deletions core/src/finalize_wallet.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <assert.h>
#include <bip32.h>
#include <curves.h>
#include <squareup/subzero/internal.pb.h>

#include "config.h"
#include "log.h"
#include "protection.h"
#include "rpc.h"
#include "strlcpy.h"

#include <assert.h>
#include <bip32.h>
#include <curves.h>
#include <squareup/subzero/internal.pb.h>

Result
handle_finalize_wallet(
const InternalCommandRequest_FinalizeWalletRequest* const in,
Expand Down
14 changes: 7 additions & 7 deletions core/src/fuzz.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "pb_decode.h"
#include "pb_encode.h"
#include "rpc.h"

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>

#include "pb_decode.h"
#include "pb_encode.h"
#include "rpc.h"

/* This is useful for debugging the fuzz driver. from nanopb docs. */
static bool fwrite_callback(pb_ostream_t *stream, const uint8_t *buf, size_t count) {
FILE *file = (FILE*) stream->state;
Expand Down
1 change: 1 addition & 0 deletions core/src/init_wallet.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "init_wallet.h"

#include "log.h"

/**
Expand Down
18 changes: 9 additions & 9 deletions core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
* nCipher wallet code.
*/

#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdbool.h>

#include "no_rollback.h"
#include "checks.h"
#include "config.h"
#include "hash.h"
#include "init.h"
#include "log.h"
#include "memzero.h"
#include "nanopb_stream.h"
#include "no_rollback.h"
#include "pb_decode.h"
#include "pb_encode.h"
#include "print.h"
#include "rpc.h"

#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>

int main(int argc, char **argv) {
int r;
bool checks_only = false;
Expand Down
4 changes: 2 additions & 2 deletions core/src/memzero.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>

#include "memzero.h"

#include <stdint.h>

/**
* This function MUST NEVER be included in a file with any other functions.
* Security relies on the fact that the linker cannot optimize function calls
Expand Down
4 changes: 2 additions & 2 deletions core/src/nanopb_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* This file is mostly a copy of nanopb/examples/network_server/common.h
*/

#include "nanopb_stream.h"

#include <pb_decode.h>
#include <pb_encode.h>
#include <sys/socket.h>
#include <sys/types.h>

#include "nanopb_stream.h"

static bool write_callback(pb_ostream_t *stream, const uint8_t *buf,
size_t count) {
int fd = (intptr_t)stream->state;
Expand Down
10 changes: 5 additions & 5 deletions core/src/ncipher/additional_checks.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <nfastapp.h>
#include <seelib.h>
#include <stdint.h>
#include <squareup/subzero/internal.pb.h> // For error codes

#include "aes_gcm_ncipher.h"
#include "checks.h"
#include "log.h"
#include "transact.h"

#include <nfastapp.h>
#include <seelib.h>
#include <squareup/subzero/internal.pb.h> // For error codes
#include <stdint.h>

extern M_KeyID master_seed_encryption_key;
extern M_KeyID pub_key_encryption_key;

Expand Down
Loading