Skip to content

Commit

Permalink
fix: cleanup and less warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Dec 28, 2024
1 parent 0667cc8 commit 9ee6aad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/embed-asset-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cat <<EOF >> src/assets.c
// vv ${name} vv
snprintf(incpath,511,"%s/%s",CJIT->tmpdir,"${name}");
if(CJIT->fresh) res = muntargz_to_path(CJIT->tmpdir,(char*)&${varname},${varname}_len);
if(CJIT->fresh) res = muntargz_to_path(CJIT->tmpdir,(const uint8_t*)&${varname},${varname}_len);
if(res!=0) { _err("Error extracting %s",incpath); return(false); }
tcc_add_include_path(CJIT->TCC, incpath);
// ^^ ${name} ^^
Expand Down
4 changes: 2 additions & 2 deletions src/cjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdarg.h> // _err/_out
#include <string.h>
#include <stdbool.h>
#include <errno.h>

#include <unistd.h> // getpid/write

#define MAX_PATH 260 // rather short paths
#define MAX_STRING 20480 // max 20KiB strings
Expand Down
6 changes: 3 additions & 3 deletions src/cjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ struct CJITState {
typedef struct CJITState CJITState;

extern CJITState* cjit_new();

bool cjit_compile_file(CJITState *cjit, const char *_path);
bool cjit_add_file(CJITState *cjit, const char *path);
extern bool cjit_setup(CJITState *cjit);
extern bool cjit_compile_file(CJITState *cjit, const char *_path);
extern bool cjit_add_file(CJITState *cjit, const char *path);

extern int cjit_exec(CJITState *cjit, int argc, char **argv);

Expand Down
5 changes: 1 addition & 4 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ static char *full_content = NULL;
static int file_load_ftw(const char *pathname,
const struct stat *sbuf,
int type, struct FTW *ftwb) {
FILE *fd;
char *content = NULL;
unsigned int len;
char *content = NULL;
if (type == FTW_F) {
size_t pathlen = strlen(pathname);
if (pathname[pathlen-1] == 'c' &&
Expand Down Expand Up @@ -276,8 +275,6 @@ static int file_load_ftw(const char *pathname,
char *dir_load(const char *path)
{
struct stat sb;
FILE *fd;
char *content = NULL;

if (stat(path, &sb) != 0) {
_err("Error: %s",path);
Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ int main(int argc, char **argv) {
cjit_free(CJIT);
unsigned int len = 0;
_err("Extract contents of: %s",opt.arg);
char *targz = file_load(opt.arg, &len);
const uint8_t *targz = (const uint8_t*)
file_load(opt.arg, &len);
if(!targz) exit(1);
if(!len) exit(1);
muntargz_to_path(".",targz,len);
Expand Down
6 changes: 3 additions & 3 deletions src/muntar.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ static int raw_to_header(mtar_header_t *h, const mtar_raw_header_t *rh)
h->devminor = (uint32_t) decodeTarOctal(rh->devminor, sizeof(rh->devminor));

h->type = (uint32_t) rh->type;
strncpy(h->name, rh->name, sizeof(rh->name));
strncpy(h->name, rh->name, sizeof(h->name));
h->name[ sizeof(h->name) - 1 ] = 0;
strncpy(h->linkname, rh->linkname, sizeof(rh->linkname));
strncpy(h->linkname, rh->linkname, sizeof(h->linkname));
h->linkname[ sizeof(h->linkname) - 1 ] = 0;
strncpy(h->path, rh->path, sizeof(rh->path));
strncpy(h->path, rh->path, sizeof(h->path));
h->path[ sizeof(h->path) - 1 ] = 0;

return MTAR_ESUCCESS;
Expand Down

0 comments on commit 9ee6aad

Please sign in to comment.