3 - needs stdlib.h instead of casting return value of malloc
6 --- db.c.orig 2011-08-28 21:43:47.000000000 +0000
8 @@ -31,6 +31,8 @@ static char *_db_c_ident_ = "@(#)$Id: db
16 #include "patchlevel.h"
17 @@ -109,7 +111,7 @@ list_init(void *data, int (*comp_func)(v
21 - lh = (lhead_t *)malloc(sizeof(lhead_t));
22 + lh = malloc(sizeof(lhead_t));
26 @@ -159,9 +161,9 @@ list_find(lhead_t *lh, void *data)
30 - else if((unsigned int)lp->l_data == (unsigned int)data)
31 + else if((uintptr_t)lp->l_data == (uintptr_t)data)
33 - else if((unsigned int)lp->l_data > (unsigned int)data)
34 + else if((uintptr_t)lp->l_data > (uintptr_t)data)
38 @@ -704,14 +706,14 @@ cddbd_check_db(int level, int fix)
41 if(sbuf.st_nlink > 1) {
42 - if(list_find(lh, (void *)(int)sbuf.st_ino)
43 + if(list_find(lh, (void *)(uintptr_t)sbuf.st_ino)
49 else if(list_add_cur(lh,
50 - (void *)(int)sbuf.st_ino) == 0) {
51 + (void *)(uintptr_t)sbuf.st_ino) == 0) {
53 "Can't malloc linked list entry.");
55 @@ -803,11 +805,11 @@ cddbd_check_db(int level, int fix)
58 if(!list_find(db->db_phase[DP_DISCID],
60 + (void *)(uintptr_t)discid)) {
61 /* Add the discid to the entry. */
63 db->db_phase[DP_DISCID],
65 + (void *)(uintptr_t)discid)) {
67 "Can't malloc list entry");
69 @@ -857,7 +859,7 @@ cddbd_check_db(int level, int fix)
71 /* Make sure discid is in the DB entry. */
72 if(!list_find(db->db_phase[DP_DISCID],
74 + (void *)(uintptr_t)discid)) {
76 "Warning: DB entry %s missing %s",
77 parstab[DP_DISCID].dp_name,
78 @@ -1232,7 +1234,7 @@ db_read(FILE *fp, char *errstr, int flag
82 - if(list_find(lh, (void *)discid) != 0) {
83 + if(list_find(lh, (void *)(uintptr_t)discid) != 0) {
84 cddbd_snprintf(errstr, CDDBBUFSIZ,
85 "duplicate disc ID on line %d",
87 @@ -1241,7 +1243,7 @@ db_read(FILE *fp, char *errstr, int flag
91 - if(list_add_cur(lh, (void *)discid) == 0) {
92 + if(list_add_cur(lh, (void *)(uintptr_t)discid) == 0) {
93 cddbd_snprintf(errstr, CDDBBUFSIZ,
94 "can't malloc list entry");
96 @@ -1642,7 +1644,7 @@ db_read(FILE *fp, char *errstr, int flag
97 /* Ensure the discid is in the DB entry. */
98 discid = db_gen_discid(db);
100 - if(list_find(db->db_phase[DP_DISCID], (void *)discid) == 0) {
101 + if(list_find(db->db_phase[DP_DISCID], (void *)(uintptr_t)discid) == 0) {
102 cddbd_snprintf(errstr, CDDBBUFSIZ,
103 "disc ID generated from track offsets (%08x) not found "
104 "in %s", discid, parstab[DP_DISCID].dp_name);
105 @@ -1659,7 +1661,7 @@ db_read(FILE *fp, char *errstr, int flag
107 for(; !list_rewound(lh); list_forw(lh)) {
109 - discid = (unsigned int)lp->l_data;
110 + discid = (unsigned int)(uintptr_t)lp->l_data;
112 if((discid & 0xFF) != db->db_trks) {
113 cddbd_snprintf(errstr, CDDBBUFSIZ,
114 @@ -1738,7 +1740,7 @@ db_write_num(FILE *fp, lhead_t *lh, db_p
115 if(!(i % n) && fputs(dp->dp_pstr, fp) == EOF)
118 - if(fprintf(fp, "%08x", (unsigned int)lp->l_data) == EOF)
119 + if(fprintf(fp, "%08lx", (unsigned long)(uintptr_t)lp->l_data) == EOF)
122 if(i == (list_count(lh) - 1) || !((i + 1) % n))
123 @@ -1783,7 +1785,7 @@ db_post(db_t *db, char *dir, unsigned in
124 cddbd_snprintf(name, sizeof(name), "%08x", discid);
126 /* Make sure discid is in the DB entry. */
127 - if(!list_find(db->db_phase[DP_DISCID], (void *)discid)) {
128 + if(!list_find(db->db_phase[DP_DISCID], (void *)(uintptr_t)discid)) {
129 cddbd_snprintf(errstr, CDDBBUFSIZ,
130 "discid %s is not in the DB entry", name);
132 @@ -2124,8 +2126,8 @@ db_unlink(char *dir, char *name)
136 - cddbd_snprintf(buf, sizeof(buf), "%s/%08x",
137 - dir, (unsigned int)lp->l_data);
138 + cddbd_snprintf(buf, sizeof(buf), "%s/%08lx",
139 + dir, (unsigned long)(uintptr_t)lp->l_data);
143 @@ -2157,8 +2159,8 @@ db_link(db_t *db, char *dir, char *name,
144 for(list_rewind(lh), list_forw(lh); !list_rewound(lh); list_forw(lh)) {
147 - cddbd_snprintf(dblink, sizeof(dblink), "%s/%08x", dir,
148 - (unsigned int)lp->l_data);
149 + cddbd_snprintf(dblink, sizeof(dblink), "%s/%08lx", dir,
150 + (unsigned long)(uintptr_t)lp->l_data);
152 /* This should already exist. */
153 if(!strcmp(dbname, dblink))