Commit 0bf396d6 authored by Warren Dukes's avatar Warren Dukes

some quick hacks to avoid signedness warnings with gcc4

git-svn-id: https://svn.musicpd.org/mpd/trunk@4387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 7fdcd56a
...@@ -38,7 +38,7 @@ extern int command_listNum; ...@@ -38,7 +38,7 @@ extern int command_listNum;
int processListOfCommands(FILE * fp, int * permission, int * expired, int processListOfCommands(FILE * fp, int * permission, int * expired,
int listOK, List * list); int listOK, List * list);
int processCommand(FILE * fp, unsigned int * permission, char * commandString); int processCommand(FILE * fp, int * permission, char * commandString);
void initCommands(); void initCommands();
......
...@@ -93,7 +93,7 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char * path) ...@@ -93,7 +93,7 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char * path)
dc->state = DECODE_STATE_DECODE; dc->state = DECODE_STATE_DECODE;
{ {
int ret, eof = 0, current = 0; int ret, eof = 0, current = 0;
unsigned char chunk[CHUNK_SIZE]; char chunk[CHUNK_SIZE];
while(!eof) { while(!eof) {
if(dc->seek) { if(dc->seek) {
......
...@@ -68,7 +68,7 @@ typedef struct _Interface { ...@@ -68,7 +68,7 @@ typedef struct _Interface {
int fd; /* file descriptor */ int fd; /* file descriptor */
FILE * fp; /* file pointer */ FILE * fp; /* file pointer */
int open; /* open/used */ int open; /* open/used */
unsigned int permission; int permission;
time_t lastTime; time_t lastTime;
List * commandList; /* for when in list mode */ List * commandList; /* for when in list mode */
int commandListOK; /* print OK after each command execution */ int commandListOK; /* print OK after each command execution */
...@@ -116,7 +116,7 @@ static void openInterface(Interface * interface, int fd) { ...@@ -116,7 +116,7 @@ static void openInterface(Interface * interface, int fd) {
#ifdef SO_SNDBUF #ifdef SO_SNDBUF
{ {
int getSize; int getSize;
int sockOptLen = sizeof(int); unsigned int sockOptLen = sizeof(int);
if(getsockopt(interface->fd,SOL_SOCKET,SO_SNDBUF, if(getsockopt(interface->fd,SOL_SOCKET,SO_SNDBUF,
(char *)&getSize,&sockOptLen) < 0) (char *)&getSize,&sockOptLen) < 0)
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
static List * permission_passwords; static List * permission_passwords;
static unsigned int permission_default; static int permission_default;
static unsigned int parsePermissions(char * string) { static int parsePermissions(char * string) {
unsigned int permission = 0; int permission = 0;
char * temp; char * temp;
char * tok; char * tok;
...@@ -72,7 +72,7 @@ void initPermissions(void) { ...@@ -72,7 +72,7 @@ void initPermissions(void) {
char * temp; char * temp;
char * cp2; char * cp2;
char * password; char * password;
unsigned int * permission; int * permission;
ConfigParam * param; ConfigParam * param;
permission_passwords = makeList(free, 1); permission_passwords = makeList(free, 1);
...@@ -104,7 +104,7 @@ void initPermissions(void) { ...@@ -104,7 +104,7 @@ void initPermissions(void) {
password = temp; password = temp;
permission = malloc(sizeof(unsigned int)); permission = malloc(sizeof(int));
*permission = parsePermissions(strtok_r(NULL,"",&cp2)); *permission = parsePermissions(strtok_r(NULL,"",&cp2));
insertInList(permission_passwords,password,permission); insertInList(permission_passwords,password,permission);
...@@ -118,11 +118,11 @@ void initPermissions(void) { ...@@ -118,11 +118,11 @@ void initPermissions(void) {
sortList(permission_passwords); sortList(permission_passwords);
} }
int getPermissionFromPassword(char * password, unsigned int * permission) { int getPermissionFromPassword(char * password, int * permission) {
void * foundPermission; void * foundPermission;
if(findInList(permission_passwords,password,&foundPermission)) { if(findInList(permission_passwords,password,&foundPermission)) {
*permission = *((unsigned int *)foundPermission); *permission = *((int *)foundPermission);
return 0; return 0;
} }
...@@ -133,6 +133,6 @@ void finishPermissions(void) { ...@@ -133,6 +133,6 @@ void finishPermissions(void) {
freeList(permission_passwords); freeList(permission_passwords);
} }
unsigned int getDefaultPermissions(void) { int getDefaultPermissions(void) {
return permission_default; return permission_default;
} }
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
void initPermissions(); void initPermissions();
int getPermissionFromPassword(char * password, unsigned int * permission); int getPermissionFromPassword(char * password, int * permission);
void finishPermissions(); void finishPermissions();
unsigned int getDefaultPermissions(); int getDefaultPermissions();
#endif #endif
...@@ -347,13 +347,13 @@ MpdTag * apeDup(char * file) { ...@@ -347,13 +347,13 @@ MpdTag * apeDup(char * file) {
MpdTag * ret = NULL; MpdTag * ret = NULL;
FILE * fp = NULL; FILE * fp = NULL;
int tagCount; int tagCount;
unsigned char * buffer = NULL; char * buffer = NULL;
unsigned char * p; char * p;
int tagLen; int tagLen;
int size; int size;
unsigned long flags; unsigned long flags;
int i; int i;
unsigned char * key; char * key;
struct { struct {
unsigned char id[8]; unsigned char id[8];
...@@ -411,10 +411,10 @@ MpdTag * apeDup(char * file) { ...@@ -411,10 +411,10 @@ MpdTag * apeDup(char * file) {
tagCount = readLEuint32(footer.tagCount); tagCount = readLEuint32(footer.tagCount);
p = buffer; p = buffer;
while(tagCount-- && tagLen > 10) { while(tagCount-- && tagLen > 10) {
size = readLEuint32(p); size = readLEuint32((unsigned char *)p);
p += 4; p += 4;
tagLen -= 4; tagLen -= 4;
flags = readLEuint32(p); flags = readLEuint32((unsigned char *)p);
p += 4; p += 4;
tagLen -= 4; tagLen -= 4;
......
...@@ -22,30 +22,31 @@ ...@@ -22,30 +22,31 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
static unsigned char * latin1ToUtf8(unsigned char c) { static char * latin1ToUtf8(char c) {
static unsigned char utf8[3]; static unsigned char utf8[3];
unsigned char uc = c;
memset(utf8,0,3); memset(utf8,0,3);
if(c < 128) utf8[0] = c; if(uc < 128) utf8[0] = uc;
else if(c<192) { else if(uc<192) {
utf8[0] = 194; utf8[0] = 194;
utf8[1] = c; utf8[1] = uc;
} }
else { else {
utf8[0] = 195; utf8[0] = 195;
utf8[1] = c-64; utf8[1] = uc-64;
} }
return utf8; return (char *)utf8;
} }
unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) { char * latin1StrToUtf8Dup(char * latin1) {
/* utf8 should have at most two char's per latin1 char */ /* utf8 should have at most two char's per latin1 char */
int len = strlen(latin1)*2+1; int len = strlen(latin1)*2+1;
unsigned char * ret = malloc(len); char * ret = malloc(len);
unsigned char * cp = ret; char * cp = ret;
unsigned char * utf8; char * utf8;
memset(ret,0,len); memset(ret,0,len);
...@@ -63,21 +64,24 @@ unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) { ...@@ -63,21 +64,24 @@ unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) {
return realloc(ret,len+1); return realloc(ret,len+1);
} }
static unsigned char utf8ToLatin1(unsigned char * utf8) { static char utf8ToLatin1(char * inUtf8) {
unsigned char c = 0; unsigned char c = 0;
unsigned char * utf8 = (unsigned char *)inUtf8;
if(utf8[0]<128) return utf8[0]; if(utf8[0]<128) return utf8[0];
else if(utf8[0]==195) c+=64; else if(utf8[0]==195) c+=64;
else if(utf8[0]!=194) return '?'; else if(utf8[0]!=194) return '?';
return c+utf8[1]; return (char)(c+utf8[1]);
} }
static int validateUtf8Char(unsigned char * utf8Char) { static int validateUtf8Char(char * inUtf8Char) {
unsigned char * utf8Char = (unsigned char *)inUtf8Char;
if(utf8Char[0]<0x80) return 1; if(utf8Char[0]<0x80) return 1;
if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) { if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) {
int count = 1; int count = 1;
unsigned char t = 1 << 5; char t = 1 << 5;
int i; int i;
while(count < 6 && (t & utf8Char[0])) { while(count < 6 && (t & utf8Char[0])) {
t = (t >> 1); t = (t >> 1);
...@@ -92,7 +96,7 @@ static int validateUtf8Char(unsigned char * utf8Char) { ...@@ -92,7 +96,7 @@ static int validateUtf8Char(unsigned char * utf8Char) {
else return 0; else return 0;
} }
int validUtf8String(unsigned char * string) { int validUtf8String(char * string) {
int ret; int ret;
while(*string) { while(*string) {
...@@ -104,11 +108,11 @@ int validUtf8String(unsigned char * string) { ...@@ -104,11 +108,11 @@ int validUtf8String(unsigned char * string) {
return 1; return 1;
} }
unsigned char * utf8StrToLatin1Dup(unsigned char * utf8) { char * utf8StrToLatin1Dup(char * utf8) {
/* utf8 should have at most two char's per latin1 char */ /* utf8 should have at most two char's per latin1 char */
int len = strlen(utf8)+1; int len = strlen(utf8)+1;
unsigned char * ret = malloc(len); char * ret = malloc(len);
unsigned char * cp = ret; char * cp = ret;
int count; int count;
memset(ret,0,len); memset(ret,0,len);
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#ifndef UTF_8_H #ifndef UTF_8_H
#define UTF_8_H #define UTF_8_H
unsigned char * latin1StrToUtf8Dup(unsigned char * latin1); char * latin1StrToUtf8Dup(char * latin1);
unsigned char * utf8StrToLatin1Dup(unsigned char * utf8); char * utf8StrToLatin1Dup(char * utf8);
int validUtf8String(unsigned char * string); int validUtf8String(char * string);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment