From: barbieri Date: Fri, 1 Feb 2008 14:29:44 +0000 (+0000) Subject: Minor warning cleanups X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=28626470fe29e711f65fa81b13ed73bba68aa826;hp=fb1a2597c11a34be8d98ad1fcf55a39ecd2e6537;p=lms Minor warning cleanups --- diff --git a/lightmediascanner/src/plugins/rm/rm.c b/lightmediascanner/src/plugins/rm/rm.c index a39de4c..6de6d81 100644 --- a/lightmediascanner/src/plugins/rm/rm.c +++ b/lightmediascanner/src/plugins/rm/rm.c @@ -39,6 +39,12 @@ #include #include +#define BE_4BYTE(a) ((((unsigned char*)a)[0] << 24) | \ + (((unsigned char*)a)[1] << 16) | \ + (((unsigned char*)a)[2] << 8) | \ + ((unsigned char*)a)[3]) +#define BE_2BYTE(a) ((((unsigned char*)a)[0] << 8) | ((unsigned char*)a)[1]) + enum StreamTypes { STREAM_TYPE_UNKNOWN = 0, STREAM_TYPE_AUDIO, @@ -93,7 +99,7 @@ _parse_file_header(int fd, struct rm_file_header *file_header) } /* convert to host byte order */ - file_header->size = ntohl(file_header->size); + file_header->size = BE_4BYTE(&file_header->size); #if 0 fprintf(stderr, "file_header type=%.*s\n", 4, file_header->type); @@ -120,7 +126,7 @@ _read_header_type_and_size(int fd, char *type, uint32_t *size) if (read(fd, size, 4) != 4) return -1; - *size = ntohl(*size); + *size = BE_4BYTE(size); #if 0 fprintf(stderr, "header type=%.*s\n", 4, type); @@ -131,7 +137,7 @@ _read_header_type_and_size(int fd, char *type, uint32_t *size) } static int -_read_string(int fd, char **out, int *out_len) +_read_string(int fd, char **out, unsigned int *out_len) { char *s; uint16_t len; @@ -139,27 +145,25 @@ _read_string(int fd, char **out, int *out_len) if (read(fd, &len, 2) == -1) return -1; - len = ntohs(len); + len = BE_2BYTE(&len); if (out) { if (len > 0) { - s = malloc(sizeof(char) * len + 1); + s = malloc(sizeof(char) * (len + 1)); if (read(fd, s, len) == -1) { free(s); return -1; } s[len] = '\0'; *out = s; - } - else { + } else *out = NULL; - } *out_len = len; - } - else { + } else lseek(fd, len, SEEK_CUR); - } + + return 0; } /* @@ -176,13 +180,9 @@ _read_string(int fd, char **out, int *out_len) * word Comment string length * byte[] Comment string */ -static int +static void _parse_cont_header(int fd, struct rm_info *info) { - uint16_t version; - uint16_t title_len; - char *title; - /* Ps.: type and size were already read */ /* ignore version */