Skip to content

Commit

Permalink
fix lto warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Aug 14, 2024
1 parent f7ae73b commit ce29ab6
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if compiler.get_id() == 'gcc'
endif

# some improvements
cflags += ['-fno-plt', '-flto', '-isystem', '-fvisibility=hidden', '-DVALA_EXTERN=extern']
cflags += ['-fno-plt', '-flto', '-isystem', '-fvisibility=hidden', '-DVALA_EXTERN=extern', '-pthread']

libc_srcs = []

Expand Down
2 changes: 1 addition & 1 deletion src/ccode.vala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public extern string url_decode (string url);
//DOC: `string run_printf (char* format, ...):`
//DOC: run command like printf
public extern string run_printf (char* format, ...);
public extern void csort (string[] arr, int n);
public extern void csort (string[] arr);
//DOC: `string trim (string data):`
//DOC: fixes excess indentation
public extern string trim (string data);
Expand Down
9 changes: 6 additions & 3 deletions src/ccode/archive-extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ extern char* build_string(char* format, ...);

#include <archive_extract.h>

#include <glib.h>


archive* archive_new(){
fdebug("new archive");
archive *data = calloc(1, sizeof(archive));
Expand Down Expand Up @@ -91,9 +94,9 @@ void archive_create(archive *data){
}
extern char* sdirname(char* path);
extern void create_dir(char* path);
extern bool isdir(char* path);
extern bool issymlink(char* path);
extern bool isfile(char* path);
extern gboolean isdir(char* path);
extern gboolean issymlink(char* path);
extern gboolean isfile(char* path);
static void archive_extract_fn(archive *data, char *path, bool all) {
fdebug("archive extract: %s => %s", data->archive_path, path);
archive_load_archive(data);
Expand Down
4 changes: 3 additions & 1 deletion src/ccode/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

#include <array.h>

#include <glib.h>

#define strdup(A) strcpy(calloc(strlen(A) + 1, sizeof(char)), A)

static int string_compare(const void* a, const void* b){
return strcmp(*(const char**)a, *(const char**)b);
}

void csort(char* arr[], int n){
void csort(char* arr[], gint n){
qsort(arr, n, sizeof(const char*), string_compare);
}

Expand Down
7 changes: 4 additions & 3 deletions src/ccode/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define strdup(A) strcpy(calloc(strlen(A) + 1, sizeof(char)), A)
#endif

#include <glib.h>

extern bool get_bool(char* value);
extern char* build_string(char* format, ...);
Expand All @@ -20,7 +21,7 @@ extern char* gettext(char* message);

static array *error_arr;

void error(int status){
void error(gint status){
if(!error_arr){
return;
}
Expand All @@ -41,14 +42,14 @@ void error(int status){
error_arr = array_new();
}

void error_add(char* message) {
void error_add(gchar* message) {
if(!error_arr){
error_arr = array_new();
}
array_add(error_arr, message);
}

bool has_error(){
gboolean has_error(){
if(!error_arr){
return false;
}
Expand Down
8 changes: 5 additions & 3 deletions src/ccode/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <stdint.h>
#include <ctype.h>

#include <glib.h>


#define FILE_OK 0
#define FILE_NOT_EXIST 1
Expand Down Expand Up @@ -66,7 +68,7 @@ void fs_sync(){
#endif
}

int issymlink(const char *filename){
gboolean issymlink(const char *filename){
if(filename == NULL){
return FALSE;
}
Expand All @@ -77,7 +79,7 @@ int issymlink(const char *filename){
return S_ISLNK(st.st_mode);
}

int isdir(char *path){
gboolean isdir(char *path){
if(path == NULL){
return FALSE;
}
Expand All @@ -99,7 +101,7 @@ int isdir(char *path){
}

#ifndef isexists
extern bool isexists(char* path);
extern gboolean isexists(char* path);
#endif

void create_dir(const char *dir) {
Expand Down
17 changes: 10 additions & 7 deletions src/ccode/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <sys/prctl.h>
#include <unistd.h>

#include <glib.h>

#ifndef which
char* which(char* path);
#endif
Expand Down Expand Up @@ -43,7 +45,8 @@ void single_instance(){

pid_t child_pid, wait_pid;
int status;
int run_args(char **command) {
gint run_args(char **command, gint length) {
(void)length;

child_pid = fork();

Expand Down Expand Up @@ -79,7 +82,7 @@ int run_args(char **command) {
}
}

int run_args_silent(char **command) {
gint run_args_silent(char **command, gint length) {

child_pid = fork();

Expand Down Expand Up @@ -122,12 +125,12 @@ int run_args_silent(char **command) {
}
}

int run(char* command){
gint run(char* command){
char* cmd[] = {"sh","-c",command, NULL};
return run_args(cmd);
return run_args(cmd, 3);
}

int run_printf(char* format, ...){
gint run_printf(char* format, ...){
char cmd[1024];
va_list args;
va_start (args, format);
Expand All @@ -138,9 +141,9 @@ int run_printf(char* format, ...){
}


int run_silent(char* command){
gint run_silent(char* command){
char* cmd[] = {"sh","-c",command, NULL};
return run_args_silent(cmd);
return run_args_silent(cmd, 3);
}

char* getoutput(const char* command) {
Expand Down
11 changes: 6 additions & 5 deletions src/ccode/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include <sys/mount.h>
#include <sys/prctl.h>


#include <value.h>

#include <glib.h>

#ifndef clear_env
void clear_env();
Expand Down Expand Up @@ -49,7 +49,7 @@ char* get_builddir_priv();
#endif

#ifndef operation_main
int operation_main(char* type, char** args);
gint operation_main(const gchar* type, gchar** args, gint length);
#endif

int isdir(char* target);
Expand All @@ -71,7 +71,8 @@ char* sandbox_rootfs;

char** get_envs();

int sandbox(char* type, char** args){
gint sandbox(const gchar* type, gchar** args, gint length){
(void)length;
if(sandbox_rootfs == NULL){
sandbox_rootfs = "/";
}
Expand All @@ -80,7 +81,7 @@ int sandbox(char* type, char** args){
}
int flag = CLONE_NEWCGROUP | CLONE_NEWNS | CLONE_NEWUSER | CLONE_NEWPID | CLONE_NEWUTS;
if(isfile("/.sandbox")){
return operation_main(type,args);
return operation_main(type,args, length);
}
pid_t pid = fork();
#if DEBUG
Expand Down Expand Up @@ -173,7 +174,7 @@ int sandbox(char* type, char** args){
if(getenv("TERM") == NULL){
setenv("TERM", "linux", 1);
}
exit(operation_main(type,new_args));
exit(operation_main(type,new_args, cur));
/*exit(execvpe("/proc/self/exe",new_args,get_envs())); */
#if DEBUG
debug(str_add("Sandbox: execute done", type));
Expand Down
6 changes: 5 additions & 1 deletion src/ccode/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <stddef.h>
#include <string.h>


#include <glib.h>

int iseq(char* str1, char* str2){
return strcmp(str1,str2) == 0;
}
Expand All @@ -30,7 +33,8 @@ long count_tab(char* data){
return cnt;
}

char* join(char* f, char** array){
gchar* join(const gchar* f, gchar** array, gint length){
(void) length;
int i = 0;
int len = 0;
/* find output size */
Expand Down
2 changes: 1 addition & 1 deletion src/data/package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public string[] list_installed_packages () {
foreach (string fname in listdir (get_storage () + "/metadata")) {
pkgs += fname[:-5];
}
csort (pkgs, pkgs.length);
csort (pkgs);
return pkgs;
}
//DOC: `package get_installed_package (string name):`
Expand Down
4 changes: 2 additions & 2 deletions src/include/error.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <stdbool.h>
#include <glib.h>
#include <stdlib.h>

extern char* build_string(char* message, ...);

void error(int status);
void error_add(char* message);
bool has_error();
gboolean has_error();

#define ferror_add(A, ...) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions src/operations/package-manager/list.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static int list_digraph_main(string[] args) {
} else {
names = repo.list_packages();
}
csort(names, names.length);
csort(names);
foreach(string name in names) {
var pkg = repo.get_package(name);
if (pkg == null) {
Expand Down Expand Up @@ -142,7 +142,7 @@ private static int list_available_main(string[] args) {
} else {
names = repo.list_packages();
}
csort(names, names.length);
csort(names);
string type = "package ";
if (get_bool("source")) {
type = "source ";
Expand Down Expand Up @@ -215,4 +215,4 @@ static void list_init() {
op.help.add_parameter("--source", _("list available source packages"));

add_operation(op);
}
}

0 comments on commit ce29ab6

Please sign in to comment.