Skip to content

Commit c3e143e

Browse files
committed
fix some log levels
1 parent fcd2dbe commit c3e143e

File tree

8 files changed

+40
-38
lines changed

8 files changed

+40
-38
lines changed

include/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdint.h>
99
#include <stdbool.h>
1010
#include <errno.h>
11+
#include <string.h>
1112
#include <inttypes.h>
1213

1314
/* Defitition */

src/cli.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ cli_write_ept(
559559
close(fd);
560560
return 5;
561561
}
562-
prln_error("write successful");
562+
prln_info("write successful");
563563
if (cli_options.rereadpart) {
564564
prln_error("trying to tell kernel to re-read partitions");
565565
/* Just don't care about return value */
@@ -612,7 +612,7 @@ cli_mode_dtoe(
612612
ept_report(&table_new);
613613
#ifdef CLI_LAZY_WRITE
614614
if (table && !ept_compare_table(table, &table_new)) {
615-
prln_error("new table is the same as the old table, no need to update");
615+
prln_info("new table is the same as the old table, no need to update");
616616
return 0;
617617
}
618618
#endif
@@ -628,7 +628,7 @@ int
628628
cli_mode_epedantic(
629629
struct ept_table const * const table
630630
){
631-
prln_error("check if EPT is pedantic");
631+
prln_info("check if EPT is pedantic");
632632
if (!table || !table->partitions_count || ept_valid_table(table)) {
633633
prln_error("EPT does not exist or is invalid, refuse to work");
634634
return -1;
@@ -725,7 +725,7 @@ cli_write_ept_from_dtb(
725725
}
726726
#ifdef CLI_LAZY_WRITE
727727
if (table && !ept_compare_table(table, &table_new)) {
728-
prln_error("corresponding table same, no need to write it");
728+
prln_info("corresponding table same, no need to write it");
729729
} else {
730730
#endif
731731
if (cli_write_ept(table, &table_new)) {
@@ -857,7 +857,7 @@ cli_mode_eedit(
857857
}
858858
#ifdef CLI_LAZY_WRITE
859859
} else {
860-
prln_error("old and new table same, no need to write");
860+
prln_info("old and new table same, no need to write");
861861
}
862862
#endif
863863
if (bhelper && cli_write_dtb_from_ept(bhelper, &table_new, capacity)) {
@@ -872,7 +872,7 @@ int
872872
cli_mode_dsnapshot(
873873
struct dtb_buffer_helper const * const bhelper
874874
){
875-
prln_error("take snapshot of partitions node in DTB");
875+
prln_info("take snapshot of partitions node in DTB");
876876
if (!bhelper || !bhelper->dtb_count) {
877877
prln_error("DTB not correct or invalid");
878878
return 1;
@@ -892,7 +892,7 @@ int
892892
cli_mode_esnapshot(
893893
struct ept_table const * const table
894894
){
895-
prln_error("take snapshot of EPT");
895+
prln_info("take snapshot of EPT");
896896
if (!table || !table->partitions_count || ept_valid_table(table)) {
897897
prln_error("EPT does not exist or is invalid, refuse to work");
898898
return 1;
@@ -996,7 +996,7 @@ cli_mode_dclone(
996996
}
997997
#ifdef CLI_LAZY_WRITE
998998
if (!dts_compare_partitions_mixed(&bhelper->dtbs->phelper, &dparts)) {
999-
prln_error("new partitions same as old, no need to write");
999+
prln_info("new partitions same as old, no need to write");
10001000
} else {
10011001
#endif
10021002
if (cli_write_dtb(bhelper, &dparts)) {
@@ -1073,7 +1073,7 @@ cli_mode_ecreate(
10731073
return -1;
10741074
}
10751075
if (!table || !ept_valid_table(table)) {
1076-
prln_error("warning, old table corrupted or not valid, continue anyway");
1076+
prln_warn("old table corrupted or not valid, continue anyway");
10771077
}
10781078
size_t const capacity = cli_get_capacity(table);
10791079
if (!capacity) {
@@ -1094,7 +1094,7 @@ cli_mode_ecreate(
10941094
}
10951095
#ifdef CLI_LAZY_WRITE
10961096
} else {
1097-
prln_error("old and new table same, no need to write");
1097+
prln_info("old and new table same, no need to write");
10981098
}
10991099
#endif
11001100
if (bhelper && cli_write_dtb_from_ept(bhelper, &table_new, capacity)) {

src/dtb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ dtb_buffer_helper_remove_partitions(
985985
}
986986
new->dtb_count = old->dtb_count;
987987
if (!(new->dtbs = malloc(new->dtb_count * sizeof *new->dtbs))) {
988-
prln_error("failed to allocate memory for entries");
988+
prln_error_with_errno("failed to allocate memory for entries");
989989
new->dtb_count = 0;
990990
return 1;
991991
}
@@ -1146,7 +1146,7 @@ dtb_compose(
11461146
prln_error("DTB size too large (0x%lx), trying to gzip it", *size);
11471147
uint8_t *buffer;
11481148
if (!(*size = gzip_zip(*dtb, *size, &buffer))) {
1149-
prln_error("failed to compose Gzipped multi-DTB");
1149+
prln_error("failed to compose gzipped multi-DTB");
11501150
free(*dtb);
11511151
dtb_free_buffer_helper(&bhelper_new);
11521152
return 6;

src/dts.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ dts_skip_node(
184184
return 0;
185185
}
186186
}
187-
prln_error("skip node");
187+
prln_error("node not properly ended");
188188
return 0;
189189
}
190190

@@ -252,10 +252,10 @@ dts_get_property_actual(
252252
current = start + i;
253253
switch (*current) {
254254
case DTS_BEGIN_NODE_ACTUAL:
255-
prln_error("DTS get property actual: child node starts, property not found, give up");
255+
prln_error("child node starts, property not found, give up");
256256
return 1;
257257
case DTS_END_NODE_ACTUAL:
258-
prln_error("DTS get property actual: node ends, give up");
258+
prln_error("node ends, give up");
259259
return 1;
260260
case DTS_PROP_ACTUAL:
261261
len_prop = bswap_32(*(current+1));
@@ -270,7 +270,7 @@ dts_get_property_actual(
270270
case DTS_NOP_ACTUAL:
271271
break;
272272
default:
273-
prln_error("DTS get property: Invalid token %"PRIu32"", bswap_32(*current));
273+
prln_error("invalid token %"PRIu32"", bswap_32(*current));
274274
return 1;
275275
}
276276
}
@@ -1439,7 +1439,7 @@ dts_dedit_parse(
14391439
prln_error("no editor");
14401440
return 2;
14411441
}
1442-
prln_error("table before editting:");
1442+
prln_info("table before editting:");
14431443
dts_report_partitions_simple(dparts);
14441444
for (unsigned i = 0; i < ehelper.count; ++i) {
14451445
if (dts_dedit_each(dparts, ehelper.editors + i)) {
@@ -1449,7 +1449,7 @@ dts_dedit_parse(
14491449
}
14501450
}
14511451
free(ehelper.editors);
1452-
prln_error("table after editting:");
1452+
prln_info("table after editting:");
14531453
dts_report_partitions_simple(dparts);
14541454
return 0;
14551455
}

src/ept.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ ept_valid_partition_name(
215215
term = false;
216216
}
217217
if (ret) {
218-
prln_error("%u illegal characters found in partition name '%s'%s", ret, name, term ? "" : ", and the previously mentioit does not end properly");
218+
prln_error("%u illegal characters found in partition name '%s'%s", ret, name, term ? "" : ", and the partition name does not end properly");
219219
}
220220
return ret;
221221
}
@@ -457,19 +457,19 @@ ept_compare_partition(
457457
return -1;
458458
}
459459
if (strncmp(part_a->name, part_b->name, MAX_PARTITION_NAME_LENGTH)) {
460-
prln_error("names different");
460+
prln_warn("names different");
461461
return 1;
462462
}
463463
if (part_a->offset != part_b->offset) {
464-
prln_error("offset different");
464+
prln_warn("offset different");
465465
return 2;
466466
}
467467
if (part_a->size != part_b->size) {
468-
prln_error("size different");
468+
prln_warn("size different");
469469
return 4;
470470
}
471471
if (part_a->mask_flags != part_b->mask_flags) {
472-
prln_error("masks different");
472+
prln_warn("masks different");
473473
return 8;
474474
}
475475
return 0;
@@ -684,7 +684,7 @@ void
684684
ept_snapshot_hex(
685685
struct ept_table const * const table
686686
){
687-
prln_error("EPT snapshot hex:");
687+
prln_info("EPT snapshot hex:");
688688
struct ept_partition const *const part_start = table->partitions;
689689
struct ept_partition const *part_current;
690690
uint32_t const pcount = util_safe_partitions_count(table->partitions_count);
@@ -704,7 +704,7 @@ void
704704
ept_snapshot_human(
705705
struct ept_table const * const table
706706
){
707-
prln_error("EPT snapshot human:");
707+
prln_info("EPT snapshot human:");
708708
struct ept_partition const *const part_start = table->partitions;
709709
struct ept_partition const *part_current;
710710
size_t offset;
@@ -855,7 +855,7 @@ ept_get_minimum_block(
855855
}
856856
#ifdef EPT_GET_MINUMUM_BLOCK_AVOID_LAST_SIZE
857857
if (part_last->offset % block) {
858-
prln_error("shift down block size from 0x%x due to part %u (%s)'s offset 0x%lx", block, table->partitions_count, part_last->name, part_last->offset);
858+
prln_warn("shift down block size from 0x%x due to part %u (%s)'s offset 0x%lx", block, table->partitions_count, part_last->name, part_last->offset);
859859
block >>= 1;
860860
change = true;
861861
}

src/gzip.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/* Local */
1111

12+
#include "common.h"
1213
#include "util.h"
1314

1415
/* Definition */
@@ -32,10 +33,10 @@ gzip_unzip_no_header(
3233
uint8_t * * const out
3334
){
3435
size_t allocated_size = util_nearest_upper_bound_with_multiply_ulong(in_size, 64, 4); // 4 times the size, nearest multiply of 64
35-
prln_error("Decompressing raw deflated data, in size %ld, allocated %ld", in_size, allocated_size);
36+
prln_info("decompressing raw deflated data, in size %ld, allocated %ld", in_size, allocated_size);
3637
*out = malloc(allocated_size);
3738
if (!*out) {
38-
prln_error("Failed to allocate memory for decompression");
39+
prln_error_with_errno("failed to allocate memory for decompression");
3940
return 0;
4041
}
4142
z_stream s;
@@ -45,7 +46,7 @@ gzip_unzip_no_header(
4546
if (inflateInit2(&s, -MAX_WBITS) != Z_OK) {
4647
free(*out);
4748
*out = NULL;
48-
prln_error("Failed to initialize Z stream for decompression");
49+
prln_error("failed to initialize Z stream for decompression");
4950
return 0;
5051
}
5152
s.next_in = in;
@@ -67,20 +68,20 @@ gzip_unzip_no_header(
6768
if (temp_buffer) {
6869
s.next_out = temp_buffer + (s.next_out - *out);
6970
*out = temp_buffer;
70-
prln_error("Re-allocated memory, now %lu", allocated_size);
71+
prln_warn("re-allocated memory, now %lu", allocated_size);
7172
} else {
7273
free(*out);
7374
*out = NULL;
7475
inflateEnd(&s);
75-
prln_error("Failed to reallocate memory for decompression");
76+
prln_error_with_errno("failed to reallocate memory for decompression");
7677
return 0;
7778
}
7879
break;
7980
default:
8081
free(*out);
8182
*out = NULL;
8283
inflateEnd(&s);
83-
prln_error("Unknown error when decompressing, errno: %d", r);
84+
prln_error("unknown error when decompressing, errno: %d", r);
8485
return 0;
8586
}
8687
}
@@ -151,7 +152,7 @@ gzip_zip(
151152
return 0;
152153
}
153154
size_t allocated_size = deflateBound(&s, in_size);
154-
prln_error("Compressing data to gzip, size %ld, allocated %ld", in_size, allocated_size);
155+
prln_error("compressing data to gzip, size %ld, allocated %ld", in_size, allocated_size);
155156
*out = malloc(allocated_size);
156157
if (!*out) {
157158
free(*out);

src/io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ io_identify_target_type_get_basic_stat(
269269
return 2;
270270
}
271271
} else if (S_ISREG(st.st_mode)) {
272-
prln_error("'%s' is a regular file, getting its size via stat", path);
272+
prln_info("'%s' is a regular file, getting its size via stat", path);
273273
type->file = IO_TARGET_TYPE_FILE_REGULAR;
274274
type->size = st.st_size;
275275
} else {
276-
prln_error("'%s' is neither a regular file nor a block device, assuming its size as 0", path);
276+
prln_info("'%s' is neither a regular file nor a block device, assuming its size as 0", path);
277277
type->file = IO_TARGET_TYPE_FILE_UNSUPPORTED;
278278
type->size = 0;
279279
}
@@ -463,7 +463,7 @@ io_seek_and_read(
463463
return 1;
464464
}
465465
if (r_seek != offset) {
466-
prln_error("seeked offset different from expected: Result 0x%lx, expected 0x%lx", r_seek, offset);
466+
prln_error("seeked offset different from expected: result 0x%lx, expected 0x%lx", r_seek, offset);
467467
return 2;
468468
}
469469
if (io_read_till_finish(fd, buffer, size)) {
@@ -583,7 +583,7 @@ io_rereadpart(
583583
return -1;
584584
}
585585
if (ioctl(fd, BLKRRPART) == -1) {
586-
prln_error_with_errno("Failed to send ioctl BLKRRPART to kernel");
586+
prln_error_with_errno("failed to send ioctl BLKRRPART to kernel");
587587
return 1;
588588
}
589589
prln_info("reread partitions success");

src/parg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ parg_parse_modifier_get_cloner(
393393
){
394394
size_t len_new_name = strlen(cloner);
395395
if (len_new_name > MAX_PARTITION_NAME_LENGTH - 1) {
396-
prln_error("New name to clone to is too long: %s", cloner);
396+
prln_error("new name to clone to is too long: %s", cloner);
397397
return 1;
398398
}
399399
strncpy(modifier->name, cloner, len_new_name);

0 commit comments

Comments
 (0)