Forráskód Böngészése

Compiler warning fixes.

Brucey 4 éve
szülő
commit
b46a614fec
3 módosított fájl, 19 hozzáadás és 12 törlés
  1. 15 8
      ctranslator.bmx
  2. 2 2
      hash.c
  3. 2 2
      stringbuffer_glue.c

+ 15 - 8
ctranslator.bmx

@@ -1757,14 +1757,21 @@ t:+"NULLNULLNULL"
 		If Not sc Then
 			s = "bbEmptyString"
 		Else
-			If Not sc.count Then
-				sc.count :+ 1
-			End If
+			sc.used :+ 1
 			s = sc.id
 		End If
 
 		Return Bra("(BBString*)&" + s)
 	End Method
+	
+	Method StringConstId:String(value:String)
+		Local sc:TStringConst = TStringConst(_app.stringConsts.ValueForKey(value))
+		If sc Then
+			sc.used :+ 1
+			Return sc.id
+		End If
+		InternalErr  "Missing const for string : " + value
+	End Method
 
 	Method TransNewObjectExpr$( expr:TNewObjectExpr )
 
@@ -2931,7 +2938,7 @@ t:+"NULLNULLNULL"
 			'Return cdecl.munged + "NullObjectTest(" + variable + ")"
 			Return variable
 		Else
-			Return Bra(Bra(TransObject(cdecl)) + "bbNullObjectTest(" + variable + ")")
+			Return Bra(Bra(TransObject(cdecl)) + "bbNullObjectTest((BBObject*)" + variable + ")")
 		End If
 	End Method
 	
@@ -3972,7 +3979,7 @@ End Rem
 		
 		_appInstance.mapStringConsts(decl.value)
 		
-		Emit ".const_value=(BBString*)&" + TStringConst(_appInstance.stringConsts.ValueForKey(decl.value)).id
+		Emit ".const_value=(BBString*)&" + StringConstId(decl.value)
 		Emit "},"
 
 	End Method
@@ -4676,7 +4683,7 @@ End Rem
 			_appInstance.mapStringConsts(value.ident)
 			_appInstance.mapStringConsts(value.Value())
 
-			Emit ".const_value=(BBString*)&" + TStringConst(_appInstance.stringConsts.ValueForKey(value.Value())).id
+			Emit ".const_value=(BBString*)&" + StringConstId(value.Value())
 			Emit "},"
 		Next
 		
@@ -6523,7 +6530,7 @@ End If
 			If s Then
 				Local key:TStringConst = TStringConst(app.stringConsts.ValueForKey(s))
 
-				If key.count > 0 Then
+				If key.used > 0 Then
 					If Not sizes.Contains(s.length) Then
 						Emit "struct BBString_" + s.length + "{BBClass_String* clas;BBULONG hash;int length;BBChar buf[" + s.length + "];};"
 						sizes.Insert(s.length, "")
@@ -6536,7 +6543,7 @@ End If
 			If s Then
 				Local key:TStringConst = TStringConst(app.stringConsts.ValueForKey(s))
 
-				If key.count > 0 Then
+				If key.used > 0 Then
 						
 					Emit "static struct BBString_" + s.length + " " + key.id + "={"
 					Emit "&bbStringClass,"

+ 2 - 2
hash.c

@@ -9,7 +9,7 @@
 #endif
 
 BBString * bmx_gen_hash(BBString * txt) {
-	char * buf[64];
+	char buf[64];
 	snprintf(buf, 64, "0x%llx", XXH3_64bits(txt->buf, txt->length * sizeof(BBChar)));
 	return bbStringFromCString(buf);
 }
@@ -27,7 +27,7 @@ void bmx_hash_update(XXH3_state_t * state, void * data, int length) {
 }
 
 BBString * bmx_hash_digest(XXH3_state_t * state) {
-	char * buf[64];
+	char buf[64];
 	snprintf(buf, 64, "%llx", XXH3_64bits_digest(state));
 	return bbStringFromCString(buf);
 }

+ 2 - 2
stringbuffer_glue.c

@@ -65,7 +65,7 @@ void bmx_stringbuffer_resize(struct MaxStringBuffer * buf, int size) {
 		if (buf->capacity * 2  > size) {
 			size = buf->capacity * 2;
 		}
-		short * newBuffer = malloc(size * sizeof(BBChar));
+		BBChar * newBuffer = (BBChar*)malloc(size * sizeof(BBChar));
 		
 		/* copy text to new buffer */
 		memcpy(newBuffer, buf->buffer, buf->count * sizeof(BBChar));
@@ -476,7 +476,7 @@ void bmx_stringbuffer_append_utf8string(struct MaxStringBuffer * buf, const char
 		const char * p = chars;
 		BBChar * b = buf->buffer + buf->count;
 		
-		while( c=*p++ & 0xff ){
+		while( (c=*p++ & 0xff) ){
 			if( c<0x80 ){
 				*b++=c;
 			}else{