Skip to content

Commit

Permalink
fixing some clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 2, 2024
1 parent 19bd289 commit b62f38d
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 75 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ add_library(droidboot_gui STATIC
common/droidboot_init.c
common/droidboot_logging.c
common/droidboot_main.c
common/droidboot_screens.c
common/droidboot_stdfunc.c
common/droidboot_theme.c
storage/droidboot_gpt.c
Expand Down Expand Up @@ -59,5 +58,5 @@ target_include_directories(droidboot_gui PUBLIC
include
.
)
target_compile_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)
target_link_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address)
target_compile_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer)
target_link_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize=undefined)
4 changes: 2 additions & 2 deletions backend/droidboot_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ droidboot_ret droidboot_driver_init(){
droidboot_log(DROIDBOOT_LOG_TRACE, "Ext4 mount returns: %d\n", r);
}
#ifdef DROIDBOOT_NO_SD_ENCRYPTED_SUPPORT
else if(userdata_offset!=0 && metadata_offset!=0){
else if(userdata_offset!=0 && metadata_offset!=0) {
droidboot_metadata_dev.part_offset = metadata_offset * droidboot_sd_blklen();
droidboot_metadata_dev.bdif->ph_bsize = droidboot_sd_blklen();
droidboot_metadata_dev.bdif->ph_bcnt = metadata_blkcnt;
Expand Down Expand Up @@ -116,7 +116,7 @@ droidboot_ret droidboot_driver_init(){
}
#endif
#ifdef DROIDBOOT_NO_SD_SUPPORT
else if(userdata_offset!=0){
else if(userdata_offset!=0) {
droidboot_userdata_settings_dev.part_offset = userdata_offset * droidboot_sd_blklen();
droidboot_userdata_settings_dev.bdif->ph_bsize = droidboot_sd_blklen();
droidboot_userdata_settings_dev.bdif->ph_bcnt = userdata_blkcnt;
Expand Down
9 changes: 4 additions & 5 deletions backend/droidboot_dualboot_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <ext4.h>

#include <droidboot_drivers.h>
#include <droidboot_screens.h>
#include <droidboot_config_parser.h>
#include <droidboot_dtb.h>

Expand All @@ -15,10 +14,10 @@

void droidboot_boot_linux_from_ext4(struct boot_entry *entry)
{
off_t kernel_raw_size = 0;
off_t ramdisk_size = 0;
off_t dtb_size = 0;
off_t dtbo_size = 0;
uint64_t kernel_raw_size = 0;
uint64_t ramdisk_size = 0;
uint64_t dtb_size = 0;
uint64_t dtbo_size = 0;
unsigned int dev_null;
size_t rb;
ext4_file fp;
Expand Down
1 change: 0 additions & 1 deletion common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
obj-y += droidboot_init.o
obj-y += droidboot_logging.o
obj-y += droidboot_main.o
obj-y += droidboot_screens.o
obj-y += droidboot_helpers.o
obj-y += droidboot_stdfunc.o
obj-y += droidboot_theme.o
2 changes: 0 additions & 2 deletions common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ OBJS += \
$(LOCAL_DIR)/droidboot_init.o \
$(LOCAL_DIR)/droidboot_logging.o \
$(LOCAL_DIR)/droidboot_main.o \
$(LOCAL_DIR)/droidboot_screens.o \
$(LOCAL_DIR)/droidboot_helpers.o \
$(LOCAL_DIR)/droidboot_stdfunc.o \
$(LOCAL_DIR)/droidboot_theme.o
Expand All @@ -16,7 +15,6 @@ MODULE_SRCS += \
$(LOCAL_DIR)/droidboot_init.c \
$(LOCAL_DIR)/droidboot_logging.c \
$(LOCAL_DIR)/droidboot_main.c \
$(LOCAL_DIR)/droidboot_screens.c \
$(LOCAL_DIR)/droidboot_helpers.c \
$(LOCAL_DIR)/droidboot_stdfunc.c \
$(LOCAL_DIR)/droidboot_theme.c
Expand Down
6 changes: 3 additions & 3 deletions common/droidboot_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const void* droidboot_load_lvgl_image_from_ext4(char* path){
}

ext4_fseek(&fp, 0, SEEK_END);
off_t entry_file_size = ext4_ftell(&fp);
uint64_t entry_file_size = ext4_ftell(&fp);
ext4_fseek(&fp, 0, SEEK_SET); /* same as rewind(f); */

off_t header_len = sizeof(lv_img_header_t); // file header struct
off_t buf_len = entry_file_size - header_len; // file size minus header size
uint64_t header_len = sizeof(lv_img_header_t); // file header struct
uint64_t buf_len = entry_file_size - header_len; // file size minus header size
lv_img_dsc_t* img_dsc = (lv_img_dsc_t*)malloc(sizeof(lv_img_dsc_t)); // image descriptor struct
unsigned char *buf = (unsigned char *)malloc(buf_len); // pixel data only

Expand Down
2 changes: 1 addition & 1 deletion common/droidboot_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void droidboot_show_dualboot_menu()
droidboot_log(DROIDBOOT_LOG_INFO, "droidboot main: found %d entries\n", droidboot_num_of_boot_entries);

// Init styles
droidboot_style_init(droidboot_global_config);
//droidboot_style_init(droidboot_global_config);

// Show dualboot menu
droidboot_draw_dualboot_menu(droidboot_entry_list, droidboot_global_config, droidboot_num_of_boot_entries);
Expand Down
11 changes: 0 additions & 11 deletions common/droidboot_screens.c

This file was deleted.

2 changes: 1 addition & 1 deletion common/droidboot_stdfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ long droidboot_strtol(const char *restrict nptr, char **restrict endptr, int bas
_Bool is_neg = 0, overflow = 0;
/* Need unsigned so (-LONG_MIN) can fit in these: */
unsigned long n = 0UL, cutoff;
int cutlim;
unsigned long cutlim;
if (base < 0 || base == 1 || base > 36) {
return 0L;
}
Expand Down
2 changes: 1 addition & 1 deletion common/droidboot_theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ lv_style_t droidboot_list_style;
lv_style_t droidboot_win_style;
lv_style_t droidboot_list_button_style;
lv_style_t droidboot_list_button_selected_style;
lv_style_t droidboot_list_timeout_style;
//lv_style_t droidboot_list_timeout_style;

void droidboot_style_init(struct global_config *global_config){
droidboot_log(DROIDBOOT_LOG_TRACE, "Current theme settings: radius: %d, bg_color: %llx, border_width: %d, border_color: %llx \n", global_config->radius, global_config->bg_color, global_config->border_width, global_config->border_color);
Expand Down
20 changes: 9 additions & 11 deletions config_parser/droidboot_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int config_parse_option(char **_dest, const char *option, const char *buffer) {
return 0;
}

int parse_boot_entry_file(struct boot_entry *entry, char *file) {
int parse_boot_entry_file(struct boot_entry *entry, const char *file) {
int ret;
ext4_file fp;
size_t rb;
Expand All @@ -87,7 +87,7 @@ int parse_boot_entry_file(struct boot_entry *entry, char *file) {
droidboot_log(DROIDBOOT_LOG_INFO, "config_parser: Going to parse file: %s\n", path);
ret=ext4_fopen (&fp, path, "r");
ext4_fseek(&fp, 0, SEEK_END);
off_t entry_file_size = ext4_ftell(&fp);
uint64_t entry_file_size = ext4_ftell(&fp);
ext4_fseek(&fp, 0, SEEK_SET); /* same as rewind(f); */

buf = malloc(entry_file_size + 1);
Expand Down Expand Up @@ -202,7 +202,7 @@ int parse_boot_entries(struct boot_entry **_entry_list) {
droidboot_log(DROIDBOOT_LOG_TRACE, "config_parser: Found direntry in entries dir\n");
if(de->inode_type==1){
struct boot_entry *entry = (entry_list+i);
ret = parse_boot_entry_file(entry, de->name);
ret = parse_boot_entry_file(entry, (const char*)de->name);
droidboot_log(DROIDBOOT_LOG_TRACE, "config_parser: found file in entries dir\n");
if(ret < 0) {
entry->error = true;
Expand Down Expand Up @@ -276,7 +276,7 @@ int parse_global_config(struct global_config *global_config) {
}

ext4_fseek(&fp, 0, SEEK_END);
long fsize = ext4_ftell(&fp);
uint64_t fsize = ext4_ftell(&fp);
ext4_fseek(&fp, 0, SEEK_SET); /* same as rewind(f); */

buf = malloc(fsize + 1);
Expand All @@ -294,8 +294,8 @@ int parse_global_config(struct global_config *global_config) {

char *timeout = NULL;
ret = config_parse_option(&timeout, "timeout", (const char *)buf);
if(ret<0) global_config->timeout =20;
else global_config->timeout = droidboot_atoi(timeout);
if(ret<0) global_config->timeout = 20;
else global_config->timeout = (int)droidboot_atoi(timeout);
droidboot_log(DROIDBOOT_LOG_INFO, "config_parser: timeout is: %d seconds\n", global_config->timeout);

// Theme parsing
Expand Down Expand Up @@ -375,12 +375,10 @@ int parse_global_config(struct global_config *global_config) {
// Button grow by default
char *button_grow_default = NULL;
ret = config_parse_option(&button_grow_default, "button_grow_default", (const char *)buf);
if(ret<0) global_config->button_grow_default = true;
if(ret < 0 || strcmp(button_grow_default, "true") == 0)
global_config->button_grow_default = true;
else
if(button_grow_default=="true")
global_config->button_grow_default = true;
else
global_config->button_grow_default = false;
global_config->button_grow_default = false;

return 0;
}
1 change: 0 additions & 1 deletion droidbootLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
common/droidboot_init.c
common/droidboot_logging.c
common/droidboot_main.c
common/droidboot_screens.c
common/droidboot_stdfunc.c
common/droidboot_theme.c
config_parser/droidboot_config.c
Expand Down
1 change: 0 additions & 1 deletion dualboot_gui/droidboot_boot_logo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <lvgl.h>
#include <droidboot_screens.h>
#include <res/abm_logo.h>

void droidboot_show_boot_logo()
Expand Down
17 changes: 7 additions & 10 deletions dualboot_gui/dualboot_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <lvgl.h>

#include <droidboot_drivers.h>
#include <droidboot_screens.h>
#include <droidboot_config_parser.h>
#include <droidboot_dualboot_backend.h>
#include <droidboot_stdfunc.h>
Expand Down Expand Up @@ -80,7 +79,7 @@ void timeout_handler(lv_timer_t * timer2)
// Lets firstly read index from metadata
int ret;
ext4_file fp;
unsigned char *buf;
char *buf;

ret=ext4_fopen (&fp, "/boot/db/last_index", "r");
if(ret!=0)
Expand Down Expand Up @@ -118,8 +117,6 @@ void droidboot_add_dualboot_menu_buttons(lv_obj_t * list1){
lv_obj_t * list_btn;

//lv_img_dsc_t img_dscs[droidboot_num_of_boot_entries];
int i;


for (int i = 0; i < droidboot_num_of_boot_entries; i++) {
char *title = malloc(strlen((droidboot_entry_list + i)->title) + 8);
Expand Down Expand Up @@ -147,7 +144,7 @@ void droidboot_add_dualboot_menu_buttons(lv_obj_t * list1){
// Set cursor to last selected entry
int ret;
ext4_file fp;
unsigned char *buf;
char *buf;

ret=ext4_fopen (&fp, "/boot/db/last_index", "r");
if(ret!=0)
Expand All @@ -166,8 +163,8 @@ void droidboot_add_dualboot_menu_buttons(lv_obj_t * list1){
ret=ext4_fclose(&fp);

droidboot_log(DROIDBOOT_LOG_INFO, "droidboot_menu: last entry is: %s\n", buf);
int index = droidboot_atoi(buf);
list_btn=lv_obj_get_child(list1, index);
uint index = droidboot_atoi(buf);
list_btn=lv_obj_get_child(list1, (int32_t)index);
lv_group_focus_obj(list_btn);
timeout_label = lv_label_create(list_btn);
lv_label_set_text_fmt(timeout_label, "\n\nBooting in %d seconds.", droidboot_global_config->timeout);
Expand All @@ -194,14 +191,14 @@ void droidboot_draw_dualboot_menu(struct boot_entry *droidboot_entry_list1, stru
lv_obj_set_size(win, lv_pct(100), lv_pct(100));
lv_obj_t * win_title = lv_win_add_title(win, "Select OS");
lv_obj_set_pos(win_title, 0, 0);
lv_obj_add_style(lv_win_get_header(win), &droidboot_win_style, 0);
lv_obj_add_style(win, &droidboot_win_style, 0);
//lv_obj_add_style(lv_win_get_header(win), &droidboot_win_style, 0);
//lv_obj_add_style(win, &droidboot_win_style, 0);

lv_obj_t * list1 = lv_list_create(win);
lv_obj_set_size(list1, lv_pct(100), lv_pct(100));
lv_obj_set_pos(list1, 0, 00);
lv_obj_align(list1, LV_ALIGN_BOTTOM_MID, 0, 0);
lv_obj_add_style(list1, &droidboot_list_style, 0);
//lv_obj_add_style(list1, &droidboot_list_style, 0);
droidboot_add_dualboot_menu_buttons(list1);

no_autoboot = false;
Expand Down
4 changes: 2 additions & 2 deletions extras/droidboot_kernel_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define MAGIC_KERNEL_ARM64 0x644d5241

droidboot_error droidboot_kernel_prepear(void* loaded_kernel, off_t kernel_raw_size, void* target_kernel, off_t max_kernel_size, off_t* kernel_actual_size)
droidboot_error droidboot_kernel_prepear(void* loaded_kernel, uint64_t kernel_raw_size, void* target_kernel, uint64_t max_kernel_size, uint64_t* kernel_actual_size)
{
int ret;
if(kernel_raw_size<=64) return DROIDBOOT_EINVAL;
Expand All @@ -33,7 +33,7 @@ droidboot_error droidboot_kernel_prepear(void* loaded_kernel, off_t kernel_raw_s
if(ret!=0)
return ret;
*kernel_actual_size = mini_gz_unpack(&gz, target_kernel, max_kernel_size);
if(kernel_actual_size<=64) return DROIDBOOT_EINVAL;
if(*kernel_actual_size<=64) return DROIDBOOT_EINVAL;
magic=*(uint32_t*)(target_kernel+0x38);
if(magic==MAGIC_KERNEL_ARM64){
droidboot_log(DROIDBOOT_LOG_INFO, "Kernel signature is correct\n");
Expand Down
2 changes: 0 additions & 2 deletions include/droidboot_drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
#include <lvgl.h>
#include <droidboot_error.h>

extern lv_indev_t * droidboot_lvgl_indev;

droidboot_ret droidboot_driver_init(void);
bool droidboot_get_sd_fail(void);
2 changes: 1 addition & 1 deletion include/droidboot_fs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#define __REBOOT_FS_UTIL_H

off_t fs_get_file_size(const char *filename);
int dir_count_entries(char *path);
int dir_count_entries(const char *path);

#endif
5 changes: 4 additions & 1 deletion include/droidboot_kernel_helper.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#pragma once
droidboot_error droidboot_kernel_prepear(void* loaded_kernel, off_t kernel_raw_size, void* target_kernel, off_t max_kernel_size, off_t* kernel_actual_size);
#include <droidboot_error.h>
#include <stdint.h>

droidboot_error droidboot_kernel_prepear(void* loaded_kernel, uint64_t kernel_raw_size, void* target_kernel, uint64_t max_kernel_size, uint64_t* kernel_actual_size);
10 changes: 0 additions & 10 deletions include/droidboot_screens.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/droidboot_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ extern lv_style_t droidboot_list_style;
extern lv_style_t droidboot_win_style;
extern lv_style_t droidboot_list_button_style;
extern lv_style_t droidboot_list_button_selected_style;
extern lv_style_t droidboot_list_timeout_style;
//extern lv_style_t droidboot_list_timeout_style;

void droidboot_style_init(struct global_config *global_config);
10 changes: 7 additions & 3 deletions storage/droidboot_gpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <droidboot_platform_common.h>
#include <libc-hack.h>

#ifndef __PACKED
#define __PACKED __attribute__((__packed__))
#endif

#define DROIDBOOT_ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
#define DROIDBOOT_ROUNDDOWN(a, b) ((a) & ~((b)-1))

Expand Down Expand Up @@ -190,9 +194,9 @@ droidboot_error droidboot_parse_gpt_on_sd()
droidboot_dump_hex(DROIDBOOT_LOG_TRACE, buf, 16);

for (j = 0; j < part_entry_cnt; j++) {
unsigned char type_guid[PARTITION_TYPE_GUID_SIZE];
unsigned char name[MAX_GPT_NAME_SIZE];
unsigned char UTF16_name[MAX_GPT_NAME_SIZE];
char type_guid[PARTITION_TYPE_GUID_SIZE];
char name[MAX_GPT_NAME_SIZE];
char UTF16_name[MAX_GPT_NAME_SIZE];
uint64_t first_lba, last_lba, size;

// guid
Expand Down
2 changes: 1 addition & 1 deletion storage/droidboot_mapped.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ file_metadata droidboot_read_file_metadata(const char *metadata_file_path, unsig

// Move to the end to get the file size
ext4_fseek(&fp, 0, SEEK_END);
long fsize = ext4_ftell(&fp);
uint64_t fsize = ext4_ftell(&fp);
ext4_fseek(&fp, 0, SEEK_SET);

// Allocate memory to read the whole file
Expand Down

0 comments on commit b62f38d

Please sign in to comment.