Browse Source

various gcc warnings fixes

ncannasse 7 years ago
parent
commit
39a7e09086
8 changed files with 24 additions and 28 deletions
  1. 7 7
      libs/openal/openal.c
  2. 2 2
      libs/sdl/sdl.c
  3. 6 6
      libs/ssl/ssl.c
  4. 1 1
      src/jit.c
  5. 4 4
      src/std/cast.c
  6. 3 3
      src/std/error.c
  7. 0 4
      src/std/maps.c
  8. 1 1
      src/std/types.c

+ 7 - 7
libs/openal/openal.c

@@ -51,7 +51,7 @@ HL_PRIM ALCdevice* HL_NAME(alc_get_contexts_device)(ALCcontext *context) {
 // Device management
 
 HL_PRIM ALCdevice* HL_NAME(alc_open_device)(vbyte *devicename) {
-	return alcOpenDevice(devicename);
+	return alcOpenDevice((char*)devicename);
 }
 
 HL_PRIM bool HL_NAME(alc_close_device)(ALCdevice *device) {
@@ -72,11 +72,11 @@ HL_PRIM void HL_NAME(alc_load_extensions)(ALCdevice *device) {
 }
 
 HL_PRIM bool HL_NAME(alc_is_extension_present)(ALCdevice *device, vbyte *extname) {
-	return alcIsExtensionPresent(device, extname) == ALC_TRUE;
+	return alcIsExtensionPresent(device, (char*)extname) == ALC_TRUE;
 }
 
 HL_PRIM int HL_NAME(alc_get_enum_value)(ALCdevice *device, vbyte *enumname) {
-	return alcGetEnumValue(device, enumname);
+	return alcGetEnumValue(device, (char*)enumname);
 }
 
 // Query function
@@ -92,7 +92,7 @@ HL_PRIM void HL_NAME(alc_get_integerv)(ALCdevice *device, int param, int size, v
 // Capture function
 
 HL_PRIM ALCdevice* HL_NAME(alc_capture_open_device)(vbyte *devicename, int frequency, int format, int buffersize) {
-	return alcCaptureOpenDevice(devicename, (ALCuint)frequency, format, buffersize);
+	return alcCaptureOpenDevice((char*)devicename, (ALCuint)frequency, format, buffersize);
 }
 
 HL_PRIM bool HL_NAME(alc_capture_close_device)(ALCdevice *device) {
@@ -231,11 +231,11 @@ HL_PRIM void HL_NAME(al_load_extensions)() {
 
 
 HL_PRIM bool HL_NAME(al_is_extension_present)(vbyte *extname) {
-	return alIsExtensionPresent(extname) == AL_TRUE;
+	return alIsExtensionPresent((char*)extname) == AL_TRUE;
 }
 
 HL_PRIM int HL_NAME(al_get_enum_value)(vbyte *ename) {
-	return alGetEnumValue(ename);
+	return alGetEnumValue((char*)ename);
 }
 
 // Set Listener parameters
@@ -600,7 +600,7 @@ DEFINE_PRIM(TCONTEXT, alc_get_thread_context, _NO_ARG);
 
 HL_PRIM ALCdevice* HL_NAME(alc_loopback_open_device_soft)(vbyte *devicename) {
 	CHECK_EXT(alcLoopbackOpenDeviceSOFT);
-	return alcLoopbackOpenDeviceSOFT(devicename);
+	return alcLoopbackOpenDeviceSOFT((char*)devicename);
 }
 
 HL_PRIM bool HL_NAME(alc_is_render_format_supported_soft)(ALCdevice *device, int freq, int channels, int type) {

+ 2 - 2
libs/sdl/sdl.c

@@ -290,7 +290,7 @@ HL_PRIM int HL_NAME(set_relative_mouse_mode)(bool enable) {
 	return SDL_SetRelativeMouseMode(enable);
 }
 
-HL_PRIM vbyte *HL_NAME(detect_keyboard_layout)() {
+HL_PRIM const char *HL_NAME(detect_keyboard_layout)() {
 	char q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q);
 	char w = SDL_GetKeyFromScancode(SDL_SCANCODE_W);
 	char y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y);
@@ -387,7 +387,7 @@ HL_PRIM bool HL_NAME(win_set_fullscreen)(SDL_Window *win, int mode) {
 }
 
 HL_PRIM void HL_NAME(win_set_title)(SDL_Window *win, vbyte *title) {
-	SDL_SetWindowTitle(win, title);
+	SDL_SetWindowTitle(win, (char*)title);
 }
 
 HL_PRIM void HL_NAME(win_set_size)(SDL_Window *win, int width, int height) {

+ 6 - 6
libs/ssl/ssl.c

@@ -127,7 +127,7 @@ int net_write(void *fd, const unsigned char *buf, size_t len) {
 }
 
 HL_PRIM void HL_NAME(ssl_set_socket)(mbedtls_ssl_context *ssl, hl_socket *socket) {
-	mbedtls_ssl_set_bio(ssl, (void*)socket->sock, net_write, net_read, NULL);
+	mbedtls_ssl_set_bio(ssl, (void*)(int_val)socket->sock, net_write, net_read, NULL);
 }
 
 HL_PRIM void HL_NAME(ssl_set_hostname)(mbedtls_ssl_context *ssl, vbyte *hostname) {
@@ -150,8 +150,8 @@ DEFINE_PRIM(_VOID, ssl_set_hostname, TSSL _BYTES);
 DEFINE_PRIM(TCERT, ssl_get_peer_certificate, TSSL);
 
 HL_PRIM int HL_NAME(ssl_send_char)(mbedtls_ssl_context *ssl, int c) {
-	char cc;
-	cc = (char)(unsigned char)c;
+	unsigned char cc;
+	cc = (unsigned char)c;
 	if (mbedtls_ssl_write(ssl, &cc, 1) == SOCKET_ERROR)
 		return block_error();
 	return 1;
@@ -470,7 +470,7 @@ HL_PRIM hl_ssl_cert *HL_NAME(cert_add_pem)(hl_ssl_cert *cert, vbyte *data) {
 		crt = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
 		mbedtls_x509_crt_init(crt);
 	}
-	len = (int)strlen(data) + 1;
+	len = (int)strlen((char*)data) + 1;
 	buf = (unsigned char *)malloc(len);
 	memcpy(buf, (char*)data, len - 1);
 	buf[len - 1] = '\0';
@@ -589,7 +589,7 @@ HL_PRIM vbyte *HL_NAME(dgst_make)(vbyte *data, int len, vbyte *alg, int *size) {
 	int mdlen, r = -1;
 	vbyte *out;
 
-	md = mbedtls_md_info_from_string(alg);
+	md = mbedtls_md_info_from_string((char*)alg);
 	if (md == NULL) {
 		hl_error("Invalid hash algorithm");
 		return NULL;
@@ -637,7 +637,7 @@ HL_PRIM bool HL_NAME(dgst_verify)(vbyte *data, int dlen, vbyte *sign, int slen,
 	int r = -1;
 	unsigned char hash[MBEDTLS_MD_MAX_SIZE];
 	
-	md = mbedtls_md_info_from_string(alg);
+	md = mbedtls_md_info_from_string((char*)alg);
 	if (md == NULL) {
 		hl_error("Invalid hash algorithm");
 		return false;

+ 1 - 1
src/jit.c

@@ -3506,7 +3506,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 					call_native(ctx,hl_dyn_call_obj,size + paramsSize);
 					if( need_dyn ) {
 						preg *r = IS_FLOAT(dst) ? REG_AT(XMM(0)) : PEAX;
-						copy(ctx,r,pmem(&p,Esp,HDYN_VALUE - sizeof(vdynamic)),dst->size);
+						copy(ctx,r,pmem(&p,Esp,HDYN_VALUE - (int)sizeof(vdynamic)),dst->size);
 						store(ctx, dst, r, false);
 					} else
 						store(ctx, dst, PEAX, false);

+ 4 - 4
src/std/cast.c

@@ -25,13 +25,13 @@
 #define TK2(a,b)		((a) | ((b)<<5))
 
 #ifndef HL_64
-#	define DYN_PAD	0,
+#	define INIT_DYN(t,v) { t, 0, v }
 #else
-#	define DYN_PAD
+#	define INIT_DYN(t,v) { t, v }
 #endif
 
-static vdynamic vdyn_true = { &hlt_bool, DYN_PAD true };
-static vdynamic vdyn_false = { &hlt_bool, DYN_PAD false };
+static vdynamic vdyn_true = INIT_DYN( &hlt_bool, true );
+static vdynamic vdyn_false = INIT_DYN( &hlt_bool, false );
 
 static void invalid_cast( hl_type *from, hl_type *to ) {
 	hl_error_msg(USTR("Can't cast %s to %s"),hl_type_str(from),hl_type_str(to));

+ 3 - 3
src/std/error.c

@@ -108,10 +108,10 @@ HL_PRIM void hl_dump_stack() {
 		uchar *str = resolve_symbol_func(addr, sym, &size);
 		if( str == NULL ) {
 			int iaddr = (int)(int_val)addr;
+			usprintf(sym,512,USTR("@0x%X"),iaddr);
 			str = sym;
-			uprintf(USTR("@0x%X\n"),iaddr);
-		} else
-			uprintf(USTR("%s\n"),str);
+		}
+		uprintf(USTR("%s\n"),str);
 	}
 }
 

+ 0 - 4
src/std/maps.c

@@ -111,10 +111,6 @@ static void hl_freelist_add( hl_free_list *f, int pos ) {
 	hl_freelist_add_range(f,pos,1);
 }
 
-static bool hl_freelist_empty( hl_free_list *f ) {
-	return f->buckets ? f->head == 0 : f->nbuckets == 0;
-}
-
 static int hl_freelist_get( hl_free_list *f ) {
 	hl_free_bucket *b;
 	int p;

+ 1 - 1
src/std/types.c

@@ -31,7 +31,7 @@ HL_PRIM hl_type hlt_f32 = { HF32 };
 HL_PRIM hl_type hlt_f64 = { HF64 };
 HL_PRIM hl_type hlt_void = { HVOID };
 HL_PRIM hl_type hlt_bool = { HBOOL };
-HL_PRIM hl_type hlt_abstract = { HABSTRACT, USTR("<abstract>") };
+HL_PRIM hl_type hlt_abstract = { HABSTRACT, {USTR("<abstract>")} };
 
 static const uchar *TSTR[] = {
 	USTR("void"), USTR("i8"), USTR("i16"), USTR("i32"), USTR("i64"), USTR("f32"), USTR("f64"),