Commit c5b524e3 authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

eliminated duplicate initialization

Local variables which are never read before the first assignment don't need initialization. Saves a few bytes of text. Also don't reset variables which are never read until function return. git-svn-id: https://svn.musicpd.org/mpd/trunk@7199 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 54b544c2
...@@ -168,7 +168,7 @@ static void addUnsupportedParam(OssData * od, int param, int val) ...@@ -168,7 +168,7 @@ static void addUnsupportedParam(OssData * od, int param, int val)
static void removeSupportedParam(OssData * od, int param, int val) static void removeSupportedParam(OssData * od, int param, int val)
{ {
int i = 0; int i;
int j = 0; int j = 0;
int idx = getIndexForParam(param); int idx = getIndexForParam(param);
...@@ -185,7 +185,7 @@ static void removeSupportedParam(OssData * od, int param, int val) ...@@ -185,7 +185,7 @@ static void removeSupportedParam(OssData * od, int param, int val)
static void removeUnsupportedParam(OssData * od, int param, int val) static void removeUnsupportedParam(OssData * od, int param, int val)
{ {
int i = 0; int i;
int j = 0; int j = 0;
int idx = getIndexForParam(param); int idx = getIndexForParam(param);
...@@ -481,7 +481,7 @@ fail: ...@@ -481,7 +481,7 @@ fail:
static int oss_openDevice(AudioOutput * audioOutput) static int oss_openDevice(AudioOutput * audioOutput)
{ {
int ret = -1; int ret;
OssData *od = audioOutput->data; OssData *od = audioOutput->data;
AudioFormat *audioFormat = &audioOutput->outAudioFormat; AudioFormat *audioFormat = &audioOutput->outAudioFormat;
......
...@@ -292,7 +292,7 @@ static int myShout_handleError(ShoutData * sd, int err) ...@@ -292,7 +292,7 @@ static int myShout_handleError(ShoutData * sd, int err)
static int write_page(ShoutData * sd) static int write_page(ShoutData * sd)
{ {
int err = 0; int err;
shout_sync(sd->shoutConn); shout_sync(sd->shoutConn);
err = shout_send(sd->shoutConn, sd->og.header, sd->og.header_len); err = shout_send(sd->shoutConn, sd->og.header, sd->og.header_len);
......
...@@ -747,7 +747,7 @@ static int handleClearError(int fd, int *permission, int argc, char *argv[]) ...@@ -747,7 +747,7 @@ static int handleClearError(int fd, int *permission, int argc, char *argv[])
static int handleList(int fd, int *permission, int argc, char *argv[]) static int handleList(int fd, int *permission, int argc, char *argv[])
{ {
int numConditionals = 0; int numConditionals;
LocateTagItem *conditionals = NULL; LocateTagItem *conditionals = NULL;
int tagType = getLocateTagItemType(argv[1]); int tagType = getLocateTagItemType(argv[1]);
int ret; int ret;
...@@ -1122,7 +1122,7 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd, ...@@ -1122,7 +1122,7 @@ static CommandEntry *getCommandEntryAndCheckArgcAndPermission(int fd,
static CommandEntry *getCommandEntryFromString(char *string, int *permission) static CommandEntry *getCommandEntryFromString(char *string, int *permission)
{ {
CommandEntry *cmd = NULL; CommandEntry *cmd;
char *argv[COMMAND_ARGV_MAX] = { NULL }; char *argv[COMMAND_ARGV_MAX] = { NULL };
int argc = buffer2array(string, argv, COMMAND_ARGV_MAX); int argc = buffer2array(string, argv, COMMAND_ARGV_MAX);
......
...@@ -81,7 +81,7 @@ static int searchInDirectory(int fd, Song * song, void *data) ...@@ -81,7 +81,7 @@ static int searchInDirectory(int fd, Song * song, void *data)
int searchForSongsIn(int fd, char *name, int numItems, LocateTagItem * items) int searchForSongsIn(int fd, char *name, int numItems, LocateTagItem * items)
{ {
int ret = -1; int ret;
int i; int i;
char **originalNeedles = xmalloc(numItems * sizeof(char *)); char **originalNeedles = xmalloc(numItems * sizeof(char *));
......
...@@ -61,7 +61,7 @@ typedef struct _OggCallbackData { ...@@ -61,7 +61,7 @@ typedef struct _OggCallbackData {
static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata) static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata)
{ {
size_t ret = 0; size_t ret;
OggCallbackData *data = (OggCallbackData *) vdata; OggCallbackData *data = (OggCallbackData *) vdata;
while (1) { while (1) {
...@@ -352,7 +352,7 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, ...@@ -352,7 +352,7 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc,
static MpdTag *oggvorbis_TagDup(char *file) static MpdTag *oggvorbis_TagDup(char *file)
{ {
MpdTag *ret = NULL; MpdTag *ret;
FILE *fp; FILE *fp;
OggVorbis_File vf; OggVorbis_File vf;
......
...@@ -108,7 +108,7 @@ int lsPlaylists(int fd, const char *utf8path) ...@@ -108,7 +108,7 @@ int lsPlaylists(int fd, const char *utf8path)
char s[MPD_PATH_MAX]; char s[MPD_PATH_MAX];
char path_max_tmp[MPD_PATH_MAX]; char path_max_tmp[MPD_PATH_MAX];
List *list = NULL; List *list = NULL;
ListNode *node = NULL; ListNode *node;
char *actualPath = rpp2app_r(path_max_tmp, char *actualPath = rpp2app_r(path_max_tmp,
utf8_to_fs_charset(path_max_tmp, utf8_to_fs_charset(path_max_tmp,
utf8path)); utf8path));
......
...@@ -87,7 +87,7 @@ static void incrPlaylistVersion(void) ...@@ -87,7 +87,7 @@ static void incrPlaylistVersion(void)
void playlistVersionChange(void) void playlistVersionChange(void)
{ {
int i = 0; int i;
for (i = 0; i < playlist.length; i++) { for (i = 0; i < playlist.length; i++) {
playlist.songMod[i] = playlist.version; playlist.songMod[i] = playlist.version;
...@@ -664,7 +664,7 @@ int addSongToPlaylist(int fd, Song * song, int *added_id) ...@@ -664,7 +664,7 @@ int addSongToPlaylist(int fd, Song * song, int *added_id)
int swapSongsInPlaylist(int fd, int song1, int song2) int swapSongsInPlaylist(int fd, int song1, int song2)
{ {
int queuedSong = -1; int queuedSong = -1;
int currentSong = -1; int currentSong;
if (song1 < 0 || song1 >= playlist.length) { if (song1 < 0 || song1 >= playlist.length) {
commandError(fd, ACK_ERROR_NO_EXIST, commandError(fd, ACK_ERROR_NO_EXIST,
......
...@@ -46,7 +46,7 @@ Song *newNullSong(void) ...@@ -46,7 +46,7 @@ Song *newNullSong(void)
Song *newSong(const char *url, int type, Directory * parentDir) Song *newSong(const char *url, int type, Directory * parentDir)
{ {
Song *song = NULL; Song *song;
if (strchr(url, '\n')) { if (strchr(url, '\n')) {
DEBUG("newSong: '%s' is not a valid uri\n", url); DEBUG("newSong: '%s' is not a valid uri\n", url);
...@@ -239,11 +239,9 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) ...@@ -239,11 +239,9 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
while (myFgets(buffer, bufferSize, fp) && 0 != strcmp(SONG_END, buffer)) { while (myFgets(buffer, bufferSize, fp) && 0 != strcmp(SONG_END, buffer)) {
if (0 == strncmp(SONG_KEY, buffer, strlen(SONG_KEY))) { if (0 == strncmp(SONG_KEY, buffer, strlen(SONG_KEY))) {
if (song) { if (song)
insertSongIntoList(list, &nextSongNode, insertSongIntoList(list, &nextSongNode,
song->url, song); song->url, song);
song = NULL;
}
song = newNullSong(); song = newNullSong();
song->url = xstrdup(buffer + strlen(SONG_KEY)); song->url = xstrdup(buffer + strlen(SONG_KEY));
...@@ -274,10 +272,8 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) ...@@ -274,10 +272,8 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir)
FATAL("songinfo: unknown line in db: %s\n", buffer); FATAL("songinfo: unknown line in db: %s\n", buffer);
} }
if (song) { if (song)
insertSongIntoList(list, &nextSongNode, song->url, song); insertSongIntoList(list, &nextSongNode, song->url, song);
song = NULL;
}
while (nextSongNode) { while (nextSongNode) {
nodeTemp = nextSongNode->nextNode; nodeTemp = nextSongNode->nextNode;
......
...@@ -137,7 +137,7 @@ void printMpdTag(int fd, MpdTag * tag) ...@@ -137,7 +137,7 @@ void printMpdTag(int fd, MpdTag * tag)
*/ */
static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4, int type) static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4, int type)
{ {
id3_utf8_t *utf8 = NULL; id3_utf8_t *utf8;
id3_latin1_t *isostr; id3_latin1_t *isostr;
char *encoding; char *encoding;
...@@ -174,7 +174,7 @@ static MpdTag *getID3Info( ...@@ -174,7 +174,7 @@ static MpdTag *getID3Info(
{ {
struct id3_frame const *frame; struct id3_frame const *frame;
id3_ucs4_t const *ucs4; id3_ucs4_t const *ucs4;
id3_utf8_t *utf8 = NULL; id3_utf8_t *utf8;
union id3_field const *field; union id3_field const *field;
unsigned int nstrings; unsigned int nstrings;
int i; int i;
...@@ -462,7 +462,7 @@ MpdTag *id3Dup(char *file) ...@@ -462,7 +462,7 @@ MpdTag *id3Dup(char *file)
MpdTag *apeDup(char *file) MpdTag *apeDup(char *file)
{ {
MpdTag *ret = NULL; MpdTag *ret = NULL;
FILE *fp = NULL; FILE *fp;
int tagCount; int tagCount;
char *buffer = NULL; char *buffer = NULL;
char *p; char *p;
...@@ -613,7 +613,7 @@ static void deleteItem(MpdTag * tag, int idx) ...@@ -613,7 +613,7 @@ static void deleteItem(MpdTag * tag, int idx)
void clearItemsFromMpdTag(MpdTag * tag, int type) void clearItemsFromMpdTag(MpdTag * tag, int type)
{ {
int i = 0; int i;
for (i = 0; i < tag->numOfItems; i++) { for (i = 0; i < tag->numOfItems; i++) {
if (tag->items[i].type == type) { if (tag->items[i].type == type) {
...@@ -650,7 +650,7 @@ void freeMpdTag(MpdTag * tag) ...@@ -650,7 +650,7 @@ void freeMpdTag(MpdTag * tag)
MpdTag *mpdTagDup(MpdTag * tag) MpdTag *mpdTagDup(MpdTag * tag)
{ {
MpdTag *ret = NULL; MpdTag *ret;
int i; int i;
if (!tag) if (!tag)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment