Apply clang-format for more source files (#795)
Apply clang-format for C source files in folder core/app-mgr, core/app-framework, and test-tools. And rename folder component_test to component-test, update zephyr build document. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -8,30 +8,30 @@
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
static unsigned char*
|
||||
read_file_to_buffer (const char *filename, int *ret_size)
|
||||
static unsigned char *
|
||||
read_file_to_buffer(const char *filename, int *ret_size)
|
||||
{
|
||||
unsigned char *buffer;
|
||||
FILE *file;
|
||||
int file_size, read_size;
|
||||
|
||||
if (!(file = fopen (filename, "r")))
|
||||
if (!(file = fopen(filename, "r")))
|
||||
return NULL;
|
||||
|
||||
fseek (file, 0, SEEK_END);
|
||||
file_size = ftell (file);
|
||||
fseek (file, 0, SEEK_SET);
|
||||
fseek(file, 0, SEEK_END);
|
||||
file_size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if (!(buffer = malloc (file_size))) {
|
||||
fclose (file);
|
||||
if (!(buffer = malloc(file_size))) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
read_size = fread (buffer, 1, file_size, file);
|
||||
fclose (file);
|
||||
read_size = fread(buffer, 1, file_size, file);
|
||||
fclose(file);
|
||||
|
||||
if (read_size < file_size) {
|
||||
free (buffer);
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -41,20 +41,19 @@ read_file_to_buffer (const char *filename, int *ret_size)
|
||||
}
|
||||
|
||||
static int
|
||||
print_help ()
|
||||
print_help()
|
||||
{
|
||||
printf ("Usage: binarydump -o <file> -n <name> input_file\n");
|
||||
printf ("Options:\n");
|
||||
printf (" -o <file> Place the output into <file>\n");
|
||||
printf (" -n <name> The name of array <file>\n");
|
||||
printf("Usage: binarydump -o <file> -n <name> input_file\n");
|
||||
printf("Options:\n");
|
||||
printf(" -o <file> Place the output into <file>\n");
|
||||
printf(" -n <name> The name of array <file>\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static bool
|
||||
bin_file_dump (const unsigned char *file, int size,
|
||||
const char *bin_file_output,
|
||||
const char *array_name)
|
||||
bin_file_dump(const unsigned char *file, int size, const char *bin_file_output,
|
||||
const char *array_name)
|
||||
{
|
||||
unsigned i = 0;
|
||||
const unsigned char *p = file, *p_end = file + size;
|
||||
@ -63,7 +62,8 @@ bin_file_dump (const unsigned char *file, int size,
|
||||
if (!file_output)
|
||||
return false;
|
||||
|
||||
fprintf(file_output, "\nunsigned char __aligned(4) %s[] = {\n ", array_name);
|
||||
fprintf(file_output, "\nunsigned char __aligned(4) %s[] = {\n ",
|
||||
array_name);
|
||||
|
||||
while (p < p_end) {
|
||||
fprintf(file_output, "0x%02X", *p++);
|
||||
@ -86,7 +86,7 @@ bin_file_dump (const unsigned char *file, int size,
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char *file;
|
||||
int size;
|
||||
@ -94,33 +94,33 @@ main (int argc, char *argv[])
|
||||
const char *bin_file_input, *array_file_output = NULL, *array_name = NULL;
|
||||
|
||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||
if (!strcmp (argv[0], "-o")) {
|
||||
if (!strcmp(argv[0], "-o")) {
|
||||
++argv;
|
||||
if (--argc == 0)
|
||||
return print_help ();
|
||||
return print_help();
|
||||
array_file_output = *argv;
|
||||
}
|
||||
else if (!strcmp (argv[0], "-n")) {
|
||||
else if (!strcmp(argv[0], "-n")) {
|
||||
++argv;
|
||||
if (--argc == 0)
|
||||
return print_help ();
|
||||
return print_help();
|
||||
array_name = *argv;
|
||||
}
|
||||
else
|
||||
return print_help ();
|
||||
return print_help();
|
||||
}
|
||||
|
||||
if (!array_file_output || !array_name)
|
||||
return print_help ();
|
||||
return print_help();
|
||||
|
||||
bin_file_input = *argv;
|
||||
|
||||
if (!(file = read_file_to_buffer (bin_file_input, &size)))
|
||||
if (!(file = read_file_to_buffer(bin_file_input, &size)))
|
||||
return -1;
|
||||
|
||||
ret = bin_file_dump (file, size, array_file_output, array_name);
|
||||
ret = bin_file_dump(file, size, array_file_output, array_name);
|
||||
|
||||
free (file);
|
||||
free(file);
|
||||
|
||||
return ret ? 0 : -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user