lk: msm: Fix files to have uniform coding style
No functional changes, just style code formatting style changes here.
Change-Id: Id3f1995ef97765b393c5c26259011c9ce1321106
diff --git a/target/msm7630_surf/tools/mkheader.c b/target/msm7630_surf/tools/mkheader.c
index fda8b67..4ebdde9 100644
--- a/target/msm7630_surf/tools/mkheader.c
+++ b/target/msm7630_surf/tools/mkheader.c
@@ -39,35 +39,46 @@
#include <sys/stat.h>
-int print_usage(){
- fprintf(stderr,"usage: mkheader <bin> <hdr> <none|unified-boot>\n");
- fprintf(stderr," mkheader <bin> <hdr> <unsecure-boot> <outbin>\n");
- fprintf(stderr," mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize>\n");
- fprintf(stderr," mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize> <certchain> <files...>\n\n");
- fprintf(stderr,"bin: Input raw appsbl binary\n");
- fprintf(stderr,"hdr: Output of appsbl header location\n");
- fprintf(stderr,"outbin: Output of the signed or unsigned apps boot location\n");
- fprintf(stderr,"maxsize: Maximum size for certificate chain\n");
- fprintf(stderr,"certchain: Output of the certchain location\n");
- fprintf(stderr,"files: Input format <bin signature> <certifcate file(s) for certificate chain>...\n");
- fprintf(stderr,"certificate chain: Files will be concatenated in order to create the certificate chain\n\n");
+int print_usage()
+{
+ fprintf(stderr, "usage: mkheader <bin> <hdr> <none|unified-boot>\n");
+ fprintf(stderr,
+ " mkheader <bin> <hdr> <unsecure-boot> <outbin>\n");
+ fprintf(stderr,
+ " mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize>\n");
+ fprintf(stderr,
+ " mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize> <certchain> <files...>\n\n");
+ fprintf(stderr, "bin: Input raw appsbl binary\n");
+ fprintf(stderr,
+ "hdr: Output of appsbl header location\n");
+ fprintf(stderr,
+ "outbin: Output of the signed or unsigned apps boot location\n");
+ fprintf(stderr,
+ "maxsize: Maximum size for certificate chain\n");
+ fprintf(stderr,
+ "certchain: Output of the certchain location\n");
+ fprintf(stderr,
+ "files: Input format <bin signature> <certifcate file(s) for certificate chain>...\n");
+ fprintf(stderr,
+ "certificate chain: Files will be concatenated in order to create the certificate chain\n\n");
return -1;
}
-int cat(FILE * in, FILE * out, unsigned size, unsigned buff_size){
+int cat(FILE * in, FILE * out, unsigned size, unsigned buff_size)
+{
unsigned bytes_left = size;
char buf[buff_size];
int ret = 0;
- while(bytes_left){
+ while (bytes_left) {
fread(buf, sizeof(char), buff_size, in);
- if(!feof(in)){
+ if (!feof(in)) {
bytes_left -= fwrite(buf, sizeof(char), buff_size, out);
- }else
+ } else
bytes_left = 0;
}
ret = ferror(in) | ferror(out);
- if(ret)
+ if (ret)
fprintf(stderr, "ERROR: Occured during file concatenation\n");
return ret;
}
@@ -86,43 +97,43 @@
int secure_boot = 0;
int fd;
- if(argc < 3) {
+ if (argc < 3) {
return print_usage();
}
if (argc == 4) {
- if(!strcmp("unified-boot",argv[3])) {
+ if (!strcmp("unified-boot", argv[3])) {
unified_boot = 1;
- }else if(!strcmp("secure-boot",argv[3])){
+ } else if (!strcmp("secure-boot", argv[3])) {
fprintf(stderr,
"ERROR: Missing arguments: [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\n");
return print_usage();
- }
- else if(!strcmp("unsecure-boot",argv[3])){
- fprintf(stderr,"ERROR: Missing arguments: outbin directory\n");
+ } else if (!strcmp("unsecure-boot", argv[3])) {
+ fprintf(stderr,
+ "ERROR: Missing arguments: outbin directory\n");
return print_usage();
}
}
if (argc > 4) {
- if(!strcmp("secure-boot",argv[3])) {
- if(argc < 9 && argc != 6){
+ if (!strcmp("secure-boot", argv[3])) {
+ if (argc < 9 && argc != 6) {
fprintf(stderr,
"ERROR: Missing argument(s): [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\n");
return print_usage();
- }
- secure_boot = 1;
- signature_size = 256; //Support SHA 256
+ }
+ secure_boot = 1;
+ signature_size = 256; //Support SHA 256
cert_chain_size = atoi(argv[5]);
- }
+ }
}
- if(stat(argv[1], &s)) {
+ if (stat(argv[1], &s)) {
perror("cannot stat binary");
return -1;
}
- if(unified_boot) {
+ if (unified_boot) {
magic = unified_boot_magic;
magic_len = sizeof(unified_boot_magic);
} else {
@@ -139,24 +150,23 @@
printf("Image Destination Pointer: 0x%x\n", base);
- magic[0] = 0x00000005; /* appsbl */
- magic[1] = 0x00000003; //Flash_partition_version /* nand */
- magic[2] = 0x00000000; //image source pointer
- magic[3] = base; //image destination pointer
- magic[4] = size + cert_chain_size + signature_size; //image size
- magic[5] = size; //code size
+ magic[0] = 0x00000005; /* appsbl */
+ magic[1] = 0x00000003; //Flash_partition_version /* nand */
+ magic[2] = 0x00000000; //image source pointer
+ magic[3] = base; //image destination pointer
+ magic[4] = size + cert_chain_size + signature_size; //image size
+ magic[5] = size; //code size
magic[6] = base + size;
magic[7] = signature_size;
magic[8] = size + base + signature_size;
magic[9] = cert_chain_size;
- if (unified_boot == 1)
- {
- magic[10] = 0x33836685; /* cookie magic number */
- magic[11] = 0x00000001; /* cookie version */
- magic[12] = 0x00000002; /* file formats */
+ if (unified_boot == 1) {
+ magic[10] = 0x33836685; /* cookie magic number */
+ magic[11] = 0x00000001; /* cookie version */
+ magic[12] = 0x00000002; /* file formats */
magic[13] = 0x00000000;
- magic[14] = 0x00000000; /* not setting size for boot.img */
+ magic[14] = 0x00000000; /* not setting size for boot.img */
magic[15] = 0x00000000;
magic[16] = 0x00000000;
magic[17] = 0x00000000;
@@ -165,11 +175,11 @@
}
fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if(fd < 0) {
+ if (fd < 0) {
perror("cannot open header for writing");
return -1;
}
- if(write(fd, magic, magic_len) != magic_len) {
+ if (write(fd, magic, magic_len) != magic_len) {
perror("cannot write header");
close(fd);
unlink(argv[2]);
@@ -177,9 +187,9 @@
}
close(fd);
- if (secure_boot && argc > 6){
- FILE * input_file;
- FILE * output_file;
+ if (secure_boot && argc > 6) {
+ FILE *input_file;
+ FILE *output_file;
unsigned buff_size = 1;
char buf[buff_size];
unsigned bytes_left;
@@ -187,14 +197,14 @@
int padding_size = 0;
int i;
- if((output_file = fopen(argv[6], "wb"))==NULL){
+ if ((output_file = fopen(argv[6], "wb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
printf("Certificate Chain Output File: %s\n", argv[6]);
- for (i = 8; i < argc; i++){
- if((input_file = fopen(argv[i], "rb"))==NULL){
+ for (i = 8; i < argc; i++) {
+ if ((input_file = fopen(argv[i], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
@@ -210,32 +220,36 @@
memset(buf, 0xFF, sizeof(buf));
padding_size = cert_chain_size - current_cert_chain_size;
- if(padding_size <0){
- fprintf(stderr, "ERROR: Input certificate chain (Size=%d) is larger than the maximum specified (Size=%d)\n",
+ if (padding_size < 0) {
+ fprintf(stderr,
+ "ERROR: Input certificate chain (Size=%d) is larger than the maximum specified (Size=%d)\n",
current_cert_chain_size, cert_chain_size);
return -1;
}
bytes_left = (padding_size > 0) ? padding_size : 0;
- while(bytes_left){
- if(!ferror(output_file))
- bytes_left -= fwrite(buf, sizeof(buf), buff_size, output_file);
- else{
- fprintf(stderr, "ERROR: Occured during certifcate chain padding\n");
+ while (bytes_left) {
+ if (!ferror(output_file))
+ bytes_left -=
+ fwrite(buf, sizeof(buf), buff_size,
+ output_file);
+ else {
+ fprintf(stderr,
+ "ERROR: Occured during certifcate chain padding\n");
return -1;
}
}
fclose(output_file);
//Concat and combine to signed image. Format [HDR][RAW APPSBOOT][PADDED CERT CHAIN]
- if((output_file = fopen(argv[4], "wb"))==NULL){
+ if ((output_file = fopen(argv[4], "wb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
printf("Image Output File: %s\n", argv[4]);
//Header
- if((input_file = fopen(argv[2], "rb"))==NULL){
+ if ((input_file = fopen(argv[2], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
@@ -245,51 +259,53 @@
fclose(input_file);
//Raw Appsbl
- if((input_file = fopen(argv[1], "rb"))==NULL){
+ if ((input_file = fopen(argv[1], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[1], &s);
- if(cat(input_file, output_file, s.st_size, buff_size))
+ if (cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Signature
- if((input_file = fopen(argv[7], "rb"))==NULL){
+ if ((input_file = fopen(argv[7], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[7], &s);
- if(cat(input_file, output_file, s.st_size, buff_size))
+ if (cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Certifcate Chain
- if((input_file = fopen(argv[6], "rb"))==NULL){
+ if ((input_file = fopen(argv[6], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
- if(cat(input_file, output_file, (current_cert_chain_size + padding_size), buff_size))
+ if (cat
+ (input_file, output_file,
+ (current_cert_chain_size + padding_size), buff_size))
return -1;
fclose(input_file);
fclose(output_file);
- }else if(argc == 5 || argc == 6){
- FILE * input_file;
- FILE * output_file;
+ } else if (argc == 5 || argc == 6) {
+ FILE *input_file;
+ FILE *output_file;
unsigned buff_size = 1;
char buf[buff_size];
//Concat and combine to unsigned image. Format [HDR][RAW APPSBOOT]
- if((output_file = fopen(argv[4], "wb"))==NULL){
+ if ((output_file = fopen(argv[4], "wb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
printf("Image Output File: %s\n", argv[4]);
//Header
- if((input_file = fopen(argv[2], "rb"))==NULL){
+ if ((input_file = fopen(argv[2], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
@@ -299,12 +315,12 @@
fclose(input_file);
//Raw Appsbl
- if((input_file = fopen(argv[1], "rb"))==NULL){
+ if ((input_file = fopen(argv[1], "rb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[1], &s);
- if(cat(input_file, output_file, s.st_size, buff_size))
+ if (cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
fclose(output_file);