Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / audio / cddbd / patches / patch-db_c
blob0fb7dd1ceabb709f0ed8787dcdd40c24955477ce
1 $NetBSD$
3 - needs stdlib.h instead of casting return value of malloc
4 - other LP64 fixes
6 --- db.c.orig   2011-08-28 21:43:47.000000000 +0000
7 +++ db.c
8 @@ -31,6 +31,8 @@ static char *_db_c_ident_ = "@(#)$Id: db
9  #include <errno.h>
10  #include <dirent.h>
11  #include <time.h>
12 +#include <stdlib.h>
13 +#include <string.h>
14  #include "list.h"
15  #include "cddbd.h"
16  #include "patchlevel.h"
17 @@ -109,7 +111,7 @@ list_init(void *data, int (*comp_func)(v
18  {
19         lhead_t *lh;
21 -       lh = (lhead_t *)malloc(sizeof(lhead_t));
22 +       lh = malloc(sizeof(lhead_t));
23         if(lh == 0)
24                 return 0;
26 @@ -159,9 +161,9 @@ list_find(lhead_t *lh, void *data)
27                         else if(cmp > 0)
28                                 return 0;
29                 }
30 -               else if((unsigned int)lp->l_data == (unsigned int)data)
31 +               else if((uintptr_t)lp->l_data == (uintptr_t)data)
32                         return lp;
33 -               else if((unsigned int)lp->l_data > (unsigned int)data)
34 +               else if((uintptr_t)lp->l_data > (uintptr_t)data)
35                         return 0;
36         }
38 @@ -704,14 +706,14 @@ cddbd_check_db(int level, int fix)
39                         islink = 0;
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)
44                                     != 0) {
45                                         links++;
46                                         islink++;
47                                         continue;
48                                 }
49                                 else if(list_add_cur(lh,
50 -                                   (void *)(int)sbuf.st_ino) == 0) {
51 +                                   (void *)(uintptr_t)sbuf.st_ino) == 0) {
52                                         cddbd_log(LOG_ERR,
53                                             "Can't malloc linked list entry.");
54                                         quit(QUIT_ERR);
55 @@ -803,11 +805,11 @@ cddbd_check_db(int level, int fix)
56                                 post = 0;
58                                 if(!list_find(db->db_phase[DP_DISCID],
59 -                                   (void *)discid)) {
60 +                                   (void *)(uintptr_t)discid)) {
61                                         /* Add the discid to the entry. */
62                                         if(!list_add_cur(
63                                             db->db_phase[DP_DISCID],
64 -                                           (void *)discid)) {
65 +                                           (void *)(uintptr_t)discid)) {
66                                                 cddbd_log(LOG_ERR, 
67                                                     "Can't malloc list entry");
69 @@ -857,7 +859,7 @@ cddbd_check_db(int level, int fix)
70                         else {
71                                 /* Make sure discid is in the DB entry. */
72                                 if(!list_find(db->db_phase[DP_DISCID],
73 -                                   (void *)discid)) {
74 +                                   (void *)(uintptr_t)discid)) {
75                                         cddbd_log(LOG_ERR,
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
79                                         return 0;
80                                 }
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",
86                                             line);
87 @@ -1241,7 +1243,7 @@ db_read(FILE *fp, char *errstr, int flag
88                                         return 0;
89                                 }
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)) {
108                 lp = list_cur(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)
116                         return 0;
118 -               if(fprintf(fp, "%08x", (unsigned int)lp->l_data) == EOF)
119 +               if(fprintf(fp, "%08lx", (unsigned long)(uintptr_t)lp->l_data) == EOF)
120                         return 0;
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)
133                     list_forw(lh)) {
134                         lp = list_cur(lh);
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);
141                         unlink(buf);
142                 }
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)) {
145                 lp = list_cur(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))