diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | libmpio/defs.h | 10 | ||||
-rw-r--r-- | libmpio/src/cis.c | 4 | ||||
-rw-r--r-- | libmpio/src/cis.h | 4 | ||||
-rw-r--r-- | libmpio/src/debug.c | 5 | ||||
-rw-r--r-- | libmpio/src/directory.c | 30 | ||||
-rw-r--r-- | libmpio/src/directory.h | 4 | ||||
-rw-r--r-- | libmpio/src/ecc.c | 3 | ||||
-rw-r--r-- | libmpio/src/fat.c | 12 | ||||
-rw-r--r-- | libmpio/src/fat.h | 5 | ||||
-rw-r--r-- | libmpio/src/id3.c | 16 | ||||
-rw-r--r-- | libmpio/src/io.c | 11 | ||||
-rw-r--r-- | libmpio/src/io.h | 5 | ||||
-rw-r--r-- | libmpio/src/mpio.c | 3 |
14 files changed, 73 insertions, 43 deletions
@@ -1,3 +1,7 @@ +2003-04-27 Markus Germeier <mager@tzi.de> + * libmpio: fixed some C code "things" found with + "paranoia" CFLAGS settings + 2003-04-21 Markus Germeier <mager@tzi.de> * libmpio/id3.c (mpio_id3_copy_tag): diff --git a/libmpio/defs.h b/libmpio/defs.h index fa9483e..0c1a6c4 100644 --- a/libmpio/defs.h +++ b/libmpio/defs.h @@ -1,7 +1,7 @@ /* -*- linux-c -*- */ /* - * $Id: defs.h,v 1.24 2003/04/23 08:53:23 crunchy Exp $ + * $Id: defs.h,v 1.25 2003/04/27 11:01:27 germeier Exp $ * * Library for USB MPIO-* * @@ -222,10 +222,10 @@ typedef struct { int dir_offset; /* these are needed for internal and external cards */ - int max_cluster; /* # of clusters actually available */ - int fat_size; /* # sectors for FAT */ - int fat_nums; /* # of FATs */ - BYTE * fat; /* *real FAT (like in block allocation :-) */ + DWORD max_cluster; /* # of clusters actually available */ + DWORD fat_size; /* # sectors for FAT */ + DWORD fat_nums; /* # of FATs */ + BYTE * fat; /* *real FAT (like in block allocation :-) */ /* needed for directory support */ mpio_directory_t *root; /* root directory */ diff --git a/libmpio/src/cis.c b/libmpio/src/cis.c index 776959d..3cc65c9 100644 --- a/libmpio/src/cis.c +++ b/libmpio/src/cis.c @@ -1,6 +1,6 @@ /* * - * $Id: cis.c,v 1.1 2003/04/23 08:34:14 crunchy Exp $ + * $Id: cis.c,v 1.2 2003/04/27 11:01:28 germeier Exp $ * * Library for USB MPIO-* * @@ -23,6 +23,8 @@ * * */ +#include <stdlib.h> + #include "cis.h" /* This data is CIS block (Card Information System) of the SmartMedia diff --git a/libmpio/src/cis.h b/libmpio/src/cis.h index 544d2fa..8d20a01 100644 --- a/libmpio/src/cis.h +++ b/libmpio/src/cis.h @@ -1,6 +1,6 @@ /* * - * $Id: cis.h,v 1.1 2003/04/23 08:34:14 crunchy Exp $ + * $Id: cis.h,v 1.2 2003/04/27 11:01:28 germeier Exp $ * * Library for USB MPIO-* * @@ -33,7 +33,7 @@ extern "C" { #endif /* generate and return a fresh CIS block */ -BYTE *mpio_cis_gen(); +BYTE *mpio_cis_gen(void); #ifdef __cplusplus } diff --git a/libmpio/src/debug.c b/libmpio/src/debug.c index a1d7240..5b4fae8 100644 --- a/libmpio/src/debug.c +++ b/libmpio/src/debug.c @@ -4,7 +4,7 @@ * Authors: Dirk Meyer <dmeyer@tzi.de> * Andreas Büsching <crunchy@tzi.de> * - * $Id: debug.c,v 1.3 2003/04/23 09:06:33 crunchy Exp $ + * $Id: debug.c,v 1.4 2003/04/27 11:01:29 germeier Exp $ */ #include "debug.h" @@ -21,6 +21,7 @@ #define LEVEL_HEXDUMP 5 #define CHECK_FD if (__debug_fd == NULL) return; +#define CHECK_FD_RETURN0 if (__debug_fd == NULL) return 0; char *__debug_color = NULL; int __debug_level = 0; @@ -296,7 +297,7 @@ _use_debug(int level) { if (__debug_level == -1) return 0; - CHECK_FD; + CHECK_FD_RETURN0; if (level <= __debug_level) { return 1; diff --git a/libmpio/src/directory.c b/libmpio/src/directory.c index fe8464c..19894c3 100644 --- a/libmpio/src/directory.c +++ b/libmpio/src/directory.c @@ -1,6 +1,6 @@ /* * - * $Id: directory.c,v 1.1 2003/04/23 08:34:14 crunchy Exp $ + * $Id: directory.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -25,6 +25,7 @@ #include <unistd.h> #include <iconv.h> +#include <ctype.h> #include "debug.h" #include "io.h" @@ -46,6 +47,7 @@ static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 }; /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */ +int date_dos2unix(unsigned short,unsigned short); int date_dos2unix(unsigned short time,unsigned short date) { @@ -83,12 +85,12 @@ mpio_charset_set(mpio_t *m, BYTE *charset) int r = 1; ic = iconv_open(UNICODE, charset); - if (ic < 0) + if (ic == ((iconv_t)(-1))) r=0; iconv_close(ic); ic = iconv_open(charset, UNICODE); - if (ic < 0) + if (ic == ((iconv_t)(-1))) r=0; iconv_close(ic); @@ -109,6 +111,9 @@ mpio_directory_init(mpio_t *m, mpio_mem_t mem, mpio_directory_t *dir, WORD self, WORD parent) { mpio_dir_entry_t *dentry; + + UNUSED(m); + UNUSED(mem); memset(dir->dir, 0, BLOCK_SIZE); memset(dir->dir, 0x20, 11); @@ -161,6 +166,9 @@ mpio_directory_is_empty(mpio_t *m, mpio_mem_t mem, mpio_directory_t *dir) mpio_dir_entry_t *dentry; BYTE r; + UNUSED(m); + UNUSED(mem); + dentry = (mpio_dir_entry_t *)dir->dir; dentry += 2; @@ -318,7 +326,7 @@ mpio_directory_cd(mpio_t *m, mpio_mem_t mem, BYTE *dir) BYTE fname[100]; WORD year; DWORD fsize; - int i, size; + int size; BYTE pwd[INFO_LINE]; mpio_directory_t *old, *new; @@ -436,7 +444,8 @@ mpio_dentry_filename_write(mpio_t *m, mpio_mem_t mem, BYTE *p, BYTE f_8_3[13]; mpio_dir_slot_t *slot; mpio_dir_entry_t *dentry; - int i, j, points; + DWORD i, j; + int points; /* generate vfat filename in UNICODE */ ic = iconv_open(UNICODE, m->charset); @@ -575,6 +584,8 @@ mpio_dentry_get_size(mpio_t *m, mpio_mem_t mem, BYTE *buffer) { mpio_dir_entry_t *dentry; + UNUSED(mem); + if (!buffer) return -1; @@ -921,7 +932,7 @@ mpio_dentry_get_time(mpio_t *m, mpio_mem_t mem, BYTE *p) mpio_fatentry_t * mpio_dentry_get_startcluster(mpio_t *m, mpio_mem_t mem, BYTE *p) { - int s; + int s, ret; DWORD cluster; BYTE i_index; mpio_dir_slot_t *dentry; @@ -942,11 +953,13 @@ mpio_dentry_get_startcluster(mpio_t *m, mpio_mem_t mem, BYTE *p) if (mem == MPIO_INTERNAL_MEM) { i_index=dentry->start[0]; - cluster = mpio_fat_internal_find_startsector(m, cluster); + ret = mpio_fat_internal_find_startsector(m, cluster); } - if (cluster < 0) + if (ret < 0) return NULL; + cluster = ret; + new = mpio_fatentry_new(m, mem, cluster, FTYPE_MUSIC); if (mem == MPIO_INTERNAL_MEM) @@ -1033,7 +1046,6 @@ mpio_dentry_find_name_8_3(mpio_t *m, BYTE mem, BYTE *filename) BYTE fname_8_3[13]; DWORD ddummy; BYTE *found = 0; - int i, j, len; p = mpio_directory_open(m, mem); while ((p) && (!found)) { diff --git a/libmpio/src/directory.h b/libmpio/src/directory.h index 4edcdb5..02d76ee 100644 --- a/libmpio/src/directory.h +++ b/libmpio/src/directory.h @@ -1,6 +1,6 @@ /* * - * $Id: directory.h,v 1.1 2003/04/23 08:34:14 crunchy Exp $ + * $Id: directory.h,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -76,6 +76,8 @@ int mpio_dentry_get_real(mpio_t *, mpio_mem_t, BYTE *, BYTE *, int, BYTE[12], WORD *, BYTE *, BYTE *, BYTE *, BYTE *, DWORD *, BYTE *); +mpio_dir_entry_t * + mpio_dentry_filename_write(mpio_t *, mpio_mem_t, BYTE *, BYTE *, int); #ifdef __cplusplus } diff --git a/libmpio/src/ecc.c b/libmpio/src/ecc.c index 95bdafd..415532e 100644 --- a/libmpio/src/ecc.c +++ b/libmpio/src/ecc.c @@ -1,6 +1,6 @@ /* * - * $Id: ecc.c,v 1.1 2003/04/23 08:34:14 crunchy Exp $ + * $Id: ecc.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -184,7 +184,6 @@ mpio_ecc_256_check(BYTE *data, BYTE *ecc) { BYTE own_ecc[3]; BYTE check[3]; - BYTE c; BYTE line, col; int v, i; diff --git a/libmpio/src/fat.c b/libmpio/src/fat.c index 27974cd..cff3084 100644 --- a/libmpio/src/fat.c +++ b/libmpio/src/fat.c @@ -1,6 +1,6 @@ /* * - * $Id: fat.c,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: fat.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -26,6 +26,7 @@ #include "fat.h" #include "io.h" #include "debug.h" +#include "directory.h" #include <string.h> #include <stdlib.h> @@ -338,7 +339,7 @@ mpio_bootblocks_read (mpio_t *m, mpio_mem_t mem) return 1; } - if (error=mpio_mbr_eval(sm)) + if ((error=mpio_mbr_eval(sm))) { debug("problem with the MBR (#%d), so I won't try to access the card any" "further.\n", error); @@ -352,7 +353,7 @@ mpio_bootblocks_read (mpio_t *m, mpio_mem_t mem) return 1; } - if (error=mpio_pbr_eval(sm)) + if ((error=mpio_pbr_eval(sm))) { debug("problem with the PBR (#%d), so I won't try to access the card any" "further.\n", error); @@ -365,7 +366,6 @@ mpio_bootblocks_read (mpio_t *m, mpio_mem_t mem) mpio_fatentry_t * mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector, BYTE ftype) { - mpio_smartmedia_t *sm; mpio_fatentry_t *new; new = malloc (sizeof(mpio_fatentry_t)); @@ -432,7 +432,7 @@ mpio_fat_read (mpio_t *m, mpio_mem_t mem, { mpio_smartmedia_t *sm; BYTE recvbuff[SECTOR_SIZE]; - int i; + DWORD i; if (mem == MPIO_INTERNAL_MEM) { @@ -665,9 +665,7 @@ mpio_fat_free_clusters(mpio_t *m, mpio_mem_t mem) { mpio_smartmedia_t *sm; mpio_fatentry_t *f; - int i; int e = 0; - int fsize; if (mem == MPIO_INTERNAL_MEM) sm = &m->internal; if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; diff --git a/libmpio/src/fat.h b/libmpio/src/fat.h index adb359b..2ed895e 100644 --- a/libmpio/src/fat.h +++ b/libmpio/src/fat.h @@ -1,6 +1,6 @@ /* * - * $Id: fat.h,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: fat.h,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -71,7 +71,8 @@ int mpio_fatentry_set_next(mpio_t *, mpio_mem_t, mpio_fatentry_t *, mpio_fatentry_t *); int mpio_fatentry_is_defect(mpio_t *, mpio_mem_t, mpio_fatentry_t *); - +int mpio_fatentry_free(mpio_t *, mpio_mem_t, mpio_fatentry_t *); + /* finding a file is fundamental different for internal mem */ int mpio_fat_internal_find_startsector(mpio_t *, BYTE); BYTE mpio_fat_internal_find_fileindex(mpio_t *); diff --git a/libmpio/src/id3.c b/libmpio/src/id3.c index e5aba36..cc11ef8 100644 --- a/libmpio/src/id3.c +++ b/libmpio/src/id3.c @@ -1,5 +1,5 @@ /* - * $Id: id3.c,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: id3.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for accessing Digit@lways MPIO players * Copyright (C) 2003 Markus Germeier @@ -23,12 +23,21 @@ #include <unistd.h> #include <fcntl.h> #include <iconv.h> +#include <string.h> +#include <stdlib.h> #include "id3.h" #include "debug.h" #include "mplib.h" +#include "mpio.h" #ifdef MPLIB +/* local declarations */ +void mpio_id3_get_content(id3_tag *, id3_tag *, int, BYTE[INFO_LINE]); +void mpio_id3_copy_tag(BYTE *, BYTE *, int *); +BYTE mpio_id3_get(mpio_t *); +BYTE mpio_id3_set(mpio_t *, BYTE); + void mpio_id3_get_content(id3_tag *tag, id3_tag *tag2, int field, BYTE out[INFO_LINE]) @@ -104,9 +113,7 @@ mpio_id3_do(mpio_t *m, BYTE *src, BYTE *tmp) id3_tag *tag, *tag2, *new_tag; id3_tag_list *tag_list; id3_tag_list new_tag_list; - id3_content *content; id3_content new_content; - id3_text_content *text_content; id3v2_tag *v2_tag; BYTE data_artist[INFO_LINE]; BYTE data_title[INFO_LINE]; @@ -119,7 +126,6 @@ mpio_id3_do(mpio_t *m, BYTE *src, BYTE *tmp) BYTE mpio_tag[INFO_LINE]; char *mpio_tag_unicode; - char *uc; iconv_t ic; int fin, fout; char *fback, *back; @@ -127,7 +133,7 @@ mpio_id3_do(mpio_t *m, BYTE *src, BYTE *tmp) if (!m->id3) return 0; - sprintf(tmp, "/tmp/MPIO-XXXXXXXXXXXXXXX", INFO_LINE); + snprintf(tmp, INFO_LINE, "/tmp/MPIO-XXXXXXXXXXXXXXX"); fd = mkstemp(tmp); if (fd==-1) return 0; diff --git a/libmpio/src/io.c b/libmpio/src/io.c index eaaadd4..b0699a4 100644 --- a/libmpio/src/io.c +++ b/libmpio/src/io.c @@ -2,7 +2,7 @@ /* * - * $Id: io.c,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: io.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -219,7 +219,7 @@ mpio_zone_init(mpio_t *m, mpio_cmd_t mem) hexdumpn(4, sm->spare+e, 0x10); debugn(2, "decoded: %04x\n", sm->zonetable[zone][block]); } - + return MPIO_OK; } DWORD @@ -248,7 +248,7 @@ mpio_zone_block_find_seq(mpio_t *m, mpio_cmd_t mem, DWORD lblock) { mpio_smartmedia_t *sm; int i, f, v; - int zone, block; + DWORD zone, block; if (mem != MPIO_EXTERNAL_MEM) { @@ -293,7 +293,6 @@ DWORD mpio_zone_block_set_free(mpio_t *m, mpio_cmd_t mem, DWORD lblock) { DWORD value; - int zone, block; mpio_smartmedia_t *sm; if (mem != MPIO_EXTERNAL_MEM) @@ -358,6 +357,8 @@ void mpio_zone_block_set(mpio_t *m, mpio_cmd_t mem, DWORD pblock) { int zone, block, pb; + + UNUSED(mem); pb = pblock / BLOCK_SECTORS; zone = pb / MPIO_ZONE_PBLOCKS; @@ -441,6 +442,8 @@ WORD mpio_zone_block_get_logical(mpio_t *m, mpio_cmd_t mem, DWORD pblock) { int zone, block, pb; + + UNUSED(mem); pb = pblock / BLOCK_SECTORS; zone = pb / MPIO_ZONE_PBLOCKS; diff --git a/libmpio/src/io.h b/libmpio/src/io.h index 9b5df11..9f338d0 100644 --- a/libmpio/src/io.h +++ b/libmpio/src/io.h @@ -2,7 +2,7 @@ /* * - * $Id: io.h,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: io.h,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -61,7 +61,8 @@ DWORD mpio_zone_block_find_free_log(mpio_t *, mpio_cmd_t, DWORD); DWORD mpio_zone_block_find_free_seq(mpio_t *, mpio_cmd_t, DWORD); /* return zone-logical block for a given physical block */ WORD mpio_zone_block_get_logical(mpio_t *, mpio_cmd_t, DWORD); - +/* */ +void mpio_zone_block_set(mpio_t *, mpio_cmd_t, DWORD); /* real I/O */ int mpio_io_set_cmdpacket(mpio_t *, mpio_cmd_t, mpio_mem_t, diff --git a/libmpio/src/mpio.c b/libmpio/src/mpio.c index 894b6f8..4a2ce10 100644 --- a/libmpio/src/mpio.c +++ b/libmpio/src/mpio.c @@ -1,6 +1,6 @@ /* * - * $Id: mpio.c,v 1.1 2003/04/23 08:34:15 crunchy Exp $ + * $Id: mpio.c,v 1.2 2003/04/27 11:01:29 germeier Exp $ * * Library for USB MPIO-* * @@ -41,6 +41,7 @@ #include "mpio.h" #include "smartmedia.h" #include "fat.h" +#include "id3.h" void mpio_bail_out(void); void mpio_init_internal(mpio_t *); |