remove all build warnings

This commit is contained in:
BernardoDeLaPlaz 2019-04-25 14:01:21 -04:00
parent 785839db5c
commit 61bf83ff56
12 changed files with 90 additions and 18 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/zod
/fakezod*
tags
TAGS

8
pkg/urbit/configure vendored
View File

@ -17,6 +17,14 @@ defmacro () {
defmacro URBIT_VERSION "\"$URBIT_VERSION\""
# propogate this info into config.h, so that we can know what __attribute__ style to use in aliases.
if [ ${CC-cc} == "gcc" ]
then
defmacro GCC 1
else
defmacro GCC 0
fi
[ -n "$MEMORY_DEBUG" ] && defmacro U3_MEMORY_DEBUG 1
[ -n "$CPU_DEBUG" ] && defmacro U3_CPU_DEBUG 1
[ -n "$EVENT_TIME_DEBUG" ] && defmacro U3_EVENT_TIME_DEBUG 1

View File

@ -3,6 +3,8 @@
#mesondefine URBIT_VERSION
#mesondefine GCC
#mesondefine U3_OS_linux
#mesondefine U3_OS_bsd
#mesondefine U3_OS_osx

View File

@ -107,3 +107,14 @@
# define u3tn(type, x) (x == 0) ? (void *)0 : ((type *) u3a_into(x))
# define u3of(type, x) (u3a_outa((type *)x))
/* turn off address sanitizer to increase speed
https://en.wikipedia.org/wiki/AddressSanitizer
*/
#if GCC
/* gcc style */
#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
/* Clang style */
#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
#endif

View File

@ -1335,3 +1335,6 @@
*/
void
u3_king_grab(void* vod_p);
c3_w
u3_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);

View File

@ -633,12 +633,22 @@ _ce_patch_apply(u3_ce_patch* pat_u)
//printf("image: sou_w %d, new %d\r\n", u3P.sou_u.pgs_w, pat_u->con_u->sou_w);
if ( u3P.nor_u.pgs_w > pat_u->con_u->nor_w ) {
ftruncate(u3P.nor_u.fid_i, u3P.nor_u.pgs_w << (u3a_page + 2));
c3_w ret_w;
ret_w = ftruncate(u3P.nor_u.fid_i, u3P.nor_u.pgs_w << (u3a_page + 2));
if (ret_w){
perror("_ce_patch_apply");
c3_assert(0);
}
}
u3P.nor_u.pgs_w = pat_u->con_u->nor_w;
if ( u3P.sou_u.pgs_w > pat_u->con_u->sou_w ) {
ftruncate(u3P.sou_u.fid_i, u3P.sou_u.pgs_w << (u3a_page + 2));
c3_w ret_w;
ret_w = ftruncate(u3P.sou_u.fid_i, u3P.sou_u.pgs_w << (u3a_page + 2));
if (ret_w){
perror("_ce_patch_apply");
c3_assert(0);
}
}
u3P.sou_u.pgs_w = pat_u->con_u->sou_w;

View File

@ -478,7 +478,7 @@ u3i_list(u3_weak one, ...);
return cut_t ? cut_w : i_w;
}
__attribute__((no_sanitize("address")))
NO_SANITIZE_ADDRESS
static u3_noun // transfer
_molt_apply(u3_noun som, // retain
c3_w len_w,
@ -504,7 +504,7 @@ u3i_list(u3_weak one, ...);
}
}
__attribute__((no_sanitize("address")))
NO_SANITIZE_ADDRESS
u3_noun
u3i_molt(u3_noun som, ...)
{

View File

@ -97,19 +97,29 @@ _cm_punt(u3_noun tax)
}
#endif
static void _write(int fd, const void *buf, size_t count)
{
if (count != write(fd, buf, count)){
fprintf(stderr, "write failed\r\n");
assert(0);
}
}
/* _cm_emergency(): write emergency text to stderr, never failing.
*/
static void
_cm_emergency(c3_c* cap_c, c3_l sig_l)
{
write(2, "\r\n", 2);
write(2, cap_c, strlen(cap_c));
_write(2, "\r\n", 2);
_write(2, cap_c, strlen(cap_c));
if ( sig_l ) {
write(2, ": ", 2);
write(2, &sig_l, 4);
_write(2, ": ", 2);
_write(2, &sig_l, 4);
}
write(2, "\r\n", 2);
_write(2, "\r\n", 2);
}
static void _cm_overflow(void *arg1, void *arg2, void *arg3)

View File

@ -161,7 +161,7 @@ u3r_at(u3_atom a, u3_noun b)
}
}
__attribute__((no_sanitize("address")))
NO_SANITIZE_ADDRESS
c3_o
u3r_mean(u3_noun som,
...)

View File

@ -26,6 +26,16 @@ static inline void _term_suck(u3_utty*, const c3_y*, ssize_t);
#define _SPIN_RATE_US 250000 // spinner rate (microseconds/frame)
#define _SPIN_IDLE_US 500000 // spinner cools down if stopped this long
static void _write(int fd, const void *buf, size_t count)
{
if (count != write(fd, buf, count)){
fprintf(stderr, "write failed\r\n");
assert(0);
}
}
/* _term_msc_out_host(): unix microseconds from current host time.
*/
static c3_d
@ -290,7 +300,7 @@ u3_term_io_exit(void)
if ( -1 == fcntl(uty_u->fid_i, F_SETFL, uty_u->cug_i) ) {
c3_assert(!"exit-fcntl");
}
write(uty_u->fid_i, "\r\n", 2);
_write(uty_u->fid_i, "\r\n", 2);
#if 0
if ( uty_u->tat_u.sun.sit_u ) {
@ -764,7 +774,7 @@ _term_try_write_str(u3_utty* uty_u,
{
// c3_i fid_i = uv_fileno(&uty_u->pop_u);
c3_i fid_i = uty_u->pop_u.io_watcher.fd; // XX old libuv
write(fid_i, hun_y, strlen(hun_y));
_write(fid_i, hun_y, strlen(hun_y));
}
/* _term_try_move_left(): move the cursor left (off-thread).
@ -1196,8 +1206,8 @@ u3_term_io_hija(void)
perror("hija-fcntl-0");
c3_assert(!"hija-fcntl");
}
write(uty_u->fid_i, "\r", 1);
write(uty_u->fid_i, uty_u->ufo_u.out.el_y,
_write(uty_u->fid_i, "\r", 1);
_write(uty_u->fid_i, uty_u->ufo_u.out.el_y,
strlen((c3_c*) uty_u->ufo_u.out.el_y));
}
return stdout;

View File

@ -15,6 +15,23 @@
#include "vere/vere.h"
c3_w u3_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
{
errno = 0;
struct dirent * tmp_u = readdir(dirp);
if (NULL == tmp_u){
*result = NULL;
return (errno); // either success or error code
} else {
memcpy(entry, tmp_u, sizeof(struct dirent));
*result = entry;
}
return(0);
}
/* _unix_down(): descend path.
*/
static c3_c*
@ -311,7 +328,7 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u)
struct dirent* out_u;
c3_w err_w;
if ( 0 != (err_w = readdir_r(rid_u, &ent_u, &out_u)) ) {
if ( 0 != (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) ) {
uL(fprintf(uH, "erroring loading pier directory %s: %s\r\n",
mon_u->dir_u.pax_c, strerror(errno)));
c3_assert(0);
@ -756,7 +773,7 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u)
struct dirent* out_u;
c3_w err_w;
if ( (err_w = readdir_r(rid_u, &ent_u, &out_u)) != 0 ) {
if ( (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) != 0 ) {
uL(fprintf(uH, "error loading directory %s: %s\r\n",
dir_u->pax_c, strerror(err_w)));
c3_assert(0);
@ -948,7 +965,7 @@ _unix_initial_update_dir(c3_c* pax_c, c3_c* bas_c)
struct dirent* out_u;
c3_w err_w;
if ( 0 != (err_w = readdir_r(rid_u, &ent_u, &out_u)) ) {
if ( 0 != (err_w = u3_readdir_r(rid_u, &ent_u, &out_u)) ) {
uL(fprintf(uH, "error loading initial directory %s: %s\r\n",
pax_c, strerror(errno)));
c3_assert(0);

View File

@ -192,7 +192,7 @@ _walk_in(const c3_c* dir_c, c3_w len_w)
struct dirent ent_n;
struct dirent* out_n;
if ( readdir_r(dir_d, &ent_n, &out_n) != 0 ) {
if ( u3_readdir_r(dir_d, &ent_n, &out_n) != 0 ) {
uL(fprintf(uH, "%s: %s\n", dir_c, strerror(errno)));
break;
}