diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-05-13 16:54:34 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-05-13 16:54:34 +0200 |
commit | 2a1e81927ef6fbf0d9c5fe4b6acf907a24eda3f7 (patch) | |
tree | 00058fd1e44c593eb918d59b71cfb4f51d1f5623 /libpiano | |
parent | 550fe90708c223ba65e7375ab8b822917ca903c3 (diff) | |
download | pianobar-2a1e81927ef6fbf0d9c5fe4b6acf907a24eda3f7.tar.gz pianobar-2a1e81927ef6fbf0d9c5fe4b6acf907a24eda3f7.tar.bz2 pianobar-2a1e81927ef6fbf0d9c5fe4b6acf907a24eda3f7.zip |
piano: Fix compiler warnings on OpenBSD
time_t can be *any* integer (signed/unsigned) or (even worse) float. Use
explicit cast to get an unsigned long. Thanks to dcoppa@openbsd again.
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/src/piano.c | 103 |
1 files changed, 54 insertions, 49 deletions
diff --git a/libpiano/src/piano.c b/libpiano/src/piano.c index 6e687b4..d8b40de 100644 --- a/libpiano/src/piano.c +++ b/libpiano/src/piano.c @@ -67,7 +67,8 @@ void PianoInit (PianoHandle_t *ph) { memset (ph, 0, sizeof (*ph)); /* route-id seems to be random. we're using time anyway... */ - snprintf (ph->routeId, sizeof (ph->routeId), "%07liP", time (NULL) % 10000000); + snprintf (ph->routeId, sizeof (ph->routeId), "%07luP", + (unsigned long) time (NULL) % 10000000); } /* free complete search result @@ -227,11 +228,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?><methodCall>" "<methodName>listener.authenticateListener</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), logindata->user, - logindata->password); + "</params></methodCall>", (unsigned long) time (NULL), + logindata->user, logindata->password); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&method=authenticateListener", ph->routeId); break; @@ -243,9 +244,10 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.getStations</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=getStations", ph->routeId, ph->user.listenerId); @@ -263,7 +265,7 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, /* FIXME: remove static, "magic" numbers */ snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>playlist.getFragment</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>0</string></value></param>" @@ -272,8 +274,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, "<param><value><string>%s</string></value></param>" "<param><value><string>0</string></value></param>" "<param><value><string>0</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->station->id, + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->station->id, PianoAudioFormatToString (reqData->format)); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=getFragment&arg1=%s&arg2=0" @@ -294,7 +296,7 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.addFeedback</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" @@ -304,8 +306,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, "<param><value></value></param>" "<param><value><boolean>%i</boolean></value></param>" "<param><value><boolean>0</boolean></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->stationId, reqData->musicId, + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->stationId, reqData->musicId, (reqData->matchingSeed == NULL) ? "" : reqData->matchingSeed, (reqData->userSeed == NULL) ? "" : reqData->userSeed, (reqData->focusTraitId == NULL) ? "" : reqData->focusTraitId, @@ -338,12 +340,13 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.setStationName</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->station->id, xmlencodedNewName); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->station->id, + xmlencodedNewName); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=setStationName&arg1=%s&arg2=%s", ph->routeId, ph->user.listenerId, reqData->station->id, @@ -362,11 +365,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.removeStation</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - station->id); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, station->id); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=removeStation&arg1=%s", ph->routeId, ph->user.listenerId, station->id); @@ -388,11 +391,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>music.search</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - xmlencodedSearchStr); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, xmlencodedSearchStr); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=search&arg1=%s", ph->routeId, ph->user.listenerId, urlencodedSearchStr); @@ -413,11 +416,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.createStation</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->type, reqData->id); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->type, reqData->id); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=createStation&arg1=%s%s", ph->routeId, @@ -435,12 +438,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.addSeed</methodName><params>" - "<param><value><int>%li</int></value></param>" + "<param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->station->id, reqData->musicId); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->station->id, reqData->musicId); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=addSeed&arg1=%s&arg2=%s", ph->routeId, ph->user.listenerId, reqData->station->id, reqData->musicId); @@ -455,11 +458,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>listener.addTiredSong</methodName><params>" - "<param><value><int>%li</int></value></param>" + "<param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - song->identity); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, song->identity); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=addTiredSong&arg1=%s", ph->routeId, ph->user.listenerId, song->identity); @@ -475,10 +478,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, memset (urlArgBuf, 0, sizeof (urlArgBuf)); snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.setQuickMix</methodName><params>" - "<param><value><int>%li</int></value></param>" + "<param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>RANDOM</string></value></param>" - "<param><value><array><data>", time (NULL), ph->user.authToken); + "<param><value><array><data>", (unsigned long) time (NULL), + ph->user.authToken); while (curStation != NULL) { /* quick mix can't contain itself */ if (!curStation->useQuickMix || curStation->isQuickMix) { @@ -513,8 +517,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, case PIANO_REQUEST_GET_GENRE_STATIONS: /* receive list of pandora's genre stations */ xmlSendBuf[0] = '\0'; - snprintf (req->urlPath, sizeof (req->urlPath), "/xml/genre?r=%li", - time (NULL)); + snprintf (req->urlPath, sizeof (req->urlPath), "/xml/genre?r=%lu", + (unsigned long) time (NULL)); break; case PIANO_REQUEST_TRANSFORM_STATION: { @@ -525,11 +529,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.transformShared</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - station->id); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, station->id); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=transformShared&arg1=%s", ph->routeId, ph->user.listenerId, station->id); @@ -545,12 +549,13 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>playlist.narrative</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->song->stationId, reqData->song->musicId); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->song->stationId, + reqData->song->musicId); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=method=narrative&arg1=%s&arg2=%s", ph->routeId, ph->user.listenerId, reqData->song->stationId, @@ -568,12 +573,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>music.getSeedSuggestions</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><int>%u</int></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - reqData->musicId, reqData->max); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, reqData->musicId, reqData->max); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=method=getSeedSuggestions&arg1=%s&arg2=%u", ph->routeId, ph->user.listenerId, reqData->musicId, reqData->max); @@ -588,12 +593,12 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.createBookmark</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - song->stationId, song->musicId); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, song->stationId, song->musicId); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=method=createBookmark&arg1=%s&arg2=%s", ph->routeId, ph->user.listenerId, song->stationId, @@ -609,11 +614,11 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, snprintf (xmlSendBuf, sizeof (xmlSendBuf), "<?xml version=\"1.0\"?>" "<methodCall><methodName>station.createArtistBookmark</methodName>" - "<params><param><value><int>%li</int></value></param>" + "<params><param><value><int>%lu</int></value></param>" "<param><value><string>%s</string></value></param>" "<param><value><string>%s</string></value></param>" - "</params></methodCall>", time (NULL), ph->user.authToken, - song->artistMusicId); + "</params></methodCall>", (unsigned long) time (NULL), + ph->user.authToken, song->artistMusicId); snprintf (req->urlPath, sizeof (req->urlPath), PIANO_RPC_PATH "rid=%s&lid=%s&method=method=createArtistBookmark&arg1=%s", ph->routeId, ph->user.listenerId, song->artistMusicId); |