From 2a1e81927ef6fbf0d9c5fe4b6acf907a24eda3f7 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 13 May 2010 16:54:34 +0200 Subject: 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. --- libpiano/src/piano.c | 103 +++++++++++++++++++++++++++------------------------ 1 file 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), "" "listener.authenticateListener" - "%li" + "%lu" "%s" "%s" - "", time (NULL), logindata->user, - logindata->password); + "", (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), "" "station.getStations" - "%li" + "%lu" "%s" - "", time (NULL), ph->user.authToken); + "", (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), "" "playlist.getFragment" - "%li" + "%lu" "%s" "%s" "0" @@ -272,8 +274,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, "%s" "0" "0" - "", time (NULL), ph->user.authToken, - reqData->station->id, + "", (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), "" "station.addFeedback" - "%li" + "%lu" "%s" "%s" "%s" @@ -304,8 +306,8 @@ PianoReturn_t PianoRequest (PianoHandle_t *ph, PianoRequest_t *req, "" "%i" "0" - "", time (NULL), ph->user.authToken, - reqData->stationId, reqData->musicId, + "", (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), "" "station.setStationName" - "%li" + "%lu" "%s" "%s" "%s" - "", time (NULL), ph->user.authToken, - reqData->station->id, xmlencodedNewName); + "", (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), "" "station.removeStation" - "%li" + "%lu" "%s" "%s" - "", time (NULL), ph->user.authToken, - station->id); + "", (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), "" "music.search" - "%li" + "%lu" "%s" "%s" - "", time (NULL), ph->user.authToken, - xmlencodedSearchStr); + "", (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), "" "station.createStation" - "%li" + "%lu" "%s" "%s%s" - "", time (NULL), ph->user.authToken, - reqData->type, reqData->id); + "", (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), "" "station.addSeed" - "%li" + "%lu" "%s" "%s" "%s" - "", time (NULL), ph->user.authToken, - reqData->station->id, reqData->musicId); + "", (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), "" "listener.addTiredSong" - "%li" + "%lu" "%s" "%s" - "", time (NULL), ph->user.authToken, - song->identity); + "", (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), "" "station.setQuickMix" - "%li" + "%lu" "%s" "RANDOM" - "", time (NULL), ph->user.authToken); + "", (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), "" "station.transformShared" - "%li" + "%lu" "%s" "%s" - "", time (NULL), ph->user.authToken, - station->id); + "", (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), "" "playlist.narrative" - "%li" + "%lu" "%s" "%s" "%s" - "", time (NULL), ph->user.authToken, - reqData->song->stationId, reqData->song->musicId); + "", (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), "" "music.getSeedSuggestions" - "%li" + "%lu" "%s" "%s" "%u" - "", time (NULL), ph->user.authToken, - reqData->musicId, reqData->max); + "", (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), "" "station.createBookmark" - "%li" + "%lu" "%s" "%s" "%s" - "", time (NULL), ph->user.authToken, - song->stationId, song->musicId); + "", (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), "" "station.createArtistBookmark" - "%li" + "%lu" "%s" "%s" - "", time (NULL), ph->user.authToken, - song->artistMusicId); + "", (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); -- cgit v1.2.3