Don't initialize globals to zero (or NULL)

Some compilers and linkers aren't smart enough to optimize this,
as global variables are implictly initialized to zero.  As a
result, binaries are a bit smaller as more goes in the .bss and
less in the text section.

git-svn-id: https://svn.musicpd.org/mpd/trunk@5254 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong 2007-01-14 03:07:53 +00:00
parent 45716f877b
commit b443363aa6
34 changed files with 88 additions and 206 deletions

View File

@ -39,12 +39,12 @@
#define AUDIO_DEVICE_STATE_LEN 19 /* strlen(AUDIO_DEVICE_STATE) */
#define AUDIO_BUFFER_SIZE 2*MAXPATHLEN
static AudioFormat audio_format = { 0, 0, 0 };
static AudioFormat audio_format;
static AudioFormat *audio_configFormat = NULL;
static AudioFormat *audio_configFormat;
static AudioOutput *audioOutputArray = NULL;
static mpd_uint8 audioOutputArraySize = 0;
static AudioOutput *audioOutputArray;
static mpd_uint8 audioOutputArraySize;
#define DEVICE_OFF 0x00
#define DEVICE_ENABLE 0x01 /* currently off, but to be turned on */
@ -53,13 +53,13 @@ static mpd_uint8 audioOutputArraySize = 0;
/* the audioEnabledArray should be stuck into shared memory, and then disable
and enable in playAudio() routine */
static mpd_uint8 *audioDeviceStates = NULL;
static mpd_uint8 *audioDeviceStates;
static mpd_uint8 audioOpened = 0;
static mpd_uint8 audioOpened;
static mpd_sint32 audioBufferSize = 0;
static char *audioBuffer = NULL;
static mpd_sint32 audioBufferPos = 0;
static mpd_sint32 audioBufferSize;
static char *audioBuffer;
static mpd_sint32 audioBufferPos;
size_t audio_device_count(void)
{

View File

@ -27,18 +27,7 @@
#include "conf.h"
#include "utils.h"
#define DISABLED_AUDIO_OUTPUT_PLUGIN(plugin) \
AudioOutputPlugin plugin = { \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL \
};
#define DISABLED_AUDIO_OUTPUT_PLUGIN(plugin) AudioOutputPlugin plugin;
typedef struct _AudioOutput AudioOutput;

View File

@ -27,7 +27,7 @@
#include <ao/ao.h>
static int driverInitCount = 0;
static int driverInitCount;
typedef struct _AoData {
int writeSize;

View File

@ -34,7 +34,7 @@
#define CONN_ATTEMPT_INTERVAL 60
static int shoutInitCount = 0;
static int shoutInitCount;
/* lots of this code blatantly stolent from bossogg/bossao2 */

View File

@ -134,8 +134,8 @@ struct _CommandEntry {
CommandListHandlerFunction listHandler;
};
static char *current_command = NULL;
static int command_listNum = 0;
static char *current_command;
static int command_listNum;
static CommandEntry *getCommandEntryFromString(char *string, int *permission);
@ -516,7 +516,7 @@ static int listHandleUpdate(int fd,
char *argv[],
struct strnode *cmdnode, CommandEntry * cmd)
{
static List *pathList = NULL;
static List *pathList;
CommandEntry *nextCmd = NULL;
struct strnode *next = cmdnode->next;

View File

@ -39,7 +39,7 @@ static int screen;
static GC blackGC, whiteGC, blueGC, yellowGC, dkyellowGC, redGC;
#endif
static int *peaks = NULL;
static int *peaks;
static int gainCurrent, gainTarget;
static struct {
@ -52,13 +52,13 @@ static struct {
} prefs;
#ifdef USE_X
static int mon_init = 0;
static int mon_init;
#endif
void CompressCfg(int show_mon, int anticlip, int target, int gainmax,
int gainsmooth, int buckets)
{
static int lastsize = 0;
static int lastsize;
prefs.show_mon = show_mon;
prefs.anticlip = anticlip;
@ -179,9 +179,9 @@ void CompressDo(void *data, unsigned int length)
int gr, gf, gn;
static int pn = -1;
#ifdef STATS
static int clip = 0;
static int clip;
#endif
static int clipped = 0;
static int clipped;
if (!peaks)
return;

View File

@ -48,7 +48,7 @@ typedef struct _configEntry {
List *configParamList;
} ConfigEntry;
static List *configEntriesList = NULL;
static List *configEntriesList;
static ConfigParam *newConfigParam(char *value, int line)
{

View File

@ -37,7 +37,7 @@
#include <unistd.h>
#include <string.h>
static int decode_pid = 0;
static int decode_pid;
void decodeSigHandler(int sig, siginfo_t * si, void *v)
{

View File

@ -59,15 +59,15 @@
#define DIRECTORY_RETURN_UPDATE 1
#define DIRECTORY_RETURN_ERROR -1
Directory *mp3rootDirectory = NULL;
static Directory *mp3rootDirectory;
time_t directory_dbModTime = 0;
static time_t directory_dbModTime;
volatile int directory_updatePid = 0;
static volatile int directory_updatePid;
volatile int directory_reReadDB = 0;
static volatile int directory_reReadDB;
volatile mpd_uint16 directory_updateJobId = 0;
static volatile mpd_uint16 directory_updateJobId;
static DirectoryList *newDirectoryList();

View File

@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>
static List *inputPlugin_list = NULL;
static List *inputPlugin_list;
void loadInputPlugin(InputPlugin * inputPlugin)
{
@ -59,7 +59,7 @@ static int stringFoundInStringArray(char **array, char *suffix)
InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
{
static ListNode *pos = NULL;
static ListNode *pos;
ListNode *node;
InputPlugin *plugin;
@ -88,7 +88,7 @@ InputPlugin *getInputPluginFromSuffix(char *suffix, unsigned int next)
InputPlugin *getInputPluginFromMimeType(char *mimeType, unsigned int next)
{
static ListNode *pos = NULL;
static ListNode *pos;
ListNode *node;
InputPlugin *plugin;

View File

@ -470,17 +470,6 @@ InputPlugin aacPlugin = {
#else
InputPlugin aacPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
};
InputPlugin aacPlugin;
#endif /* HAVE_FAAD */

View File

@ -183,17 +183,6 @@ InputPlugin audiofilePlugin = {
#else
InputPlugin audiofilePlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL
};
InputPlugin audiofilePlugin;
#endif /* HAVE_AUDIOFILE */

View File

@ -525,17 +525,6 @@ InputPlugin flacPlugin = {
#else /* !HAVE_FLAC */
InputPlugin flacPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
};
InputPlugin flacPlugin;
#endif /* HAVE_FLAC */

View File

@ -92,8 +92,8 @@ static MDRIVER drv_mpd = {
VC_VoiceRealVolume
};
static int mod_mikModInitiated = 0;
static int mod_mikModInitError = 0;
static int mod_mikModInitiated;
static int mod_mikModInitError;
static int mod_initMikMod(void)
{
@ -285,17 +285,6 @@ InputPlugin modPlugin = {
#else
InputPlugin modPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL
};
InputPlugin modPlugin;
#endif /* HAVE_AUDIOFILE */

View File

@ -1087,17 +1087,6 @@ InputPlugin mp3Plugin = {
};
#else
InputPlugin mp3Plugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL
};
InputPlugin mp3Plugin;
#endif

View File

@ -450,17 +450,6 @@ InputPlugin mp4Plugin = {
#else
InputPlugin mp4Plugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL
};
InputPlugin mp4Plugin;
#endif /* HAVE_FAAD */

View File

@ -355,17 +355,6 @@ InputPlugin mpcPlugin = {
#else
InputPlugin mpcPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL
};
InputPlugin mpcPlugin;
#endif

View File

@ -418,17 +418,6 @@ InputPlugin oggflacPlugin = {
#else /* !HAVE_FLAC */
InputPlugin oggflacPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
};
InputPlugin oggflacPlugin;
#endif /* HAVE_OGGFLAC */

View File

@ -429,17 +429,6 @@ InputPlugin oggvorbisPlugin = {
#else /* !HAVE_OGGVORBIS */
InputPlugin oggvorbisPlugin = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
};
InputPlugin oggvorbisPlugin;
#endif /* HAVE_OGGVORBIS */

View File

@ -47,10 +47,10 @@
#define HTTP_REDIRECT_MAX 10
static char *proxyHost = NULL;
static char *proxyPort = NULL;
static char *proxyUser = NULL;
static char *proxyPassword = NULL;
static char *proxyHost;
static char *proxyPort;
static char *proxyUser;
static char *proxyPassword;
static int bufferSize = HTTP_BUFFER_SIZE_DEFAULT;
static int prebufferSize = HTTP_PREBUFFER_SIZE_DEFAULT;

View File

@ -56,7 +56,7 @@
#define INTERFACE_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (8192*1024)
/* set this to zero to indicate we have no possible interfaces */
static int interface_max_connections = 0; /*INTERFACE_MAX_CONNECTIONS_DEFAULT; */
static int interface_max_connections; /*INTERFACE_MAX_CONNECTIONS_DEFAULT; */
static int interface_timeout = INTERFACE_TIMEOUT_DEFAULT;
static size_t interface_max_command_list_size =
INTERFACE_MAX_COMMAND_LIST_DEFAULT;
@ -70,9 +70,9 @@ static struct ioOps *ioList;
static long int interface_list_cache_size = 32;
/* shared globally between all interfaces: */
static struct strnode *list_cache = NULL;
static struct strnode *list_cache_head = NULL;
static struct strnode *list_cache_tail = NULL;
static struct strnode *list_cache;
static struct strnode *list_cache_head;
static struct strnode *list_cache_tail;
typedef struct _Interface {
char buffer[INTERFACE_MAX_BUFFER_LENGTH];
@ -98,7 +98,7 @@ typedef struct _Interface {
int send_buf_alloc; /* bytes actually allocated */
} Interface;
static Interface *interfaces = NULL;
static Interface *interfaces;
static void flushInterfaceBuffer(Interface * interface);
@ -731,7 +731,7 @@ static void flushInterfaceBuffer(Interface * interface)
int interfacePrintWithFD(int fd, char *buffer, int buflen)
{
static int i = 0;
static int i;
int copylen;
Interface *interface;

View File

@ -45,9 +45,9 @@
ERROR("maybe MPD is still running?\n"); \
} while (0);
int *listenSockets = NULL;
int numberOfListenSockets = 0;
static int boundPort = 0;
static int *listenSockets;
static int numberOfListenSockets;
static int boundPort;
static int establishListen(unsigned int port,
struct sockaddr *addrp, socklen_t addrlen)

View File

@ -31,11 +31,11 @@
#endif
#endif
static char *localeCharset = NULL;
static char *localeCharset;
char *utf8ToLocaleCharset(char *str)
{
static char *ret = NULL;
static char *ret;
if (localeCharset)
ret = convCharset(localeCharset, "UTF-8", str, ret);

View File

@ -30,13 +30,13 @@
#include <time.h>
static unsigned int logLevel = LOG_LEVEL_LOW;
static int warningFlushed = 0;
static int warningFlushed;
static int stdout_mode = 1;
static char *warningBuffer = NULL;
static char *warningBuffer;
static int out_fd = -1;
static int err_fd = -1;
static const char *out_filename = NULL;
static const char *err_filename = NULL;
static const char *out_filename;
static const char *err_filename;
/* redirect stdin to /dev/null to work around a libao bug */
static void redirect_stdin(void)
@ -60,7 +60,7 @@ static void redirect_logs(void)
static const char *log_date(void)
{
static char buf[16] = { '\0' };
static char buf[16];
time_t t = time(NULL);
strftime(buf, 16, "%b %d %H:%M : ", localtime(&t));
return buf;

View File

@ -30,7 +30,7 @@
static mpd_sint16 currentChunk = -1;
static mpd_sint8 currentMetaChunk = -1;
static mpd_sint8 sendMetaChunk = 0;
static mpd_sint8 sendMetaChunk;
void clearAllMetaChunkSets(OutputBuffer * cb)
{
@ -76,8 +76,8 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
mpd_uint16 chunkLeft;
char *data;
size_t datalen;
static char *convBuffer = NULL;
static long convBufferLen = 0;
static char *convBuffer;
static long convBufferLen;
if (cmpAudioFormat(&(cb->audioFormat), &(dc->audioFormat)) == 0) {
data = dataIn;
@ -158,7 +158,7 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag)
{
int nextChunk;
static MpdTag *last = NULL;
static MpdTag *last;
if (!cb->acceptMetadata || !tag) {
sendMetaChunk = 0;

View File

@ -34,11 +34,11 @@
const char *musicDir;
static const char *playlistDir;
static char *fsCharset = NULL;
static char *fsCharset;
char *fsCharsetToUtf8(char *str)
{
static char *ret = NULL;
static char *ret;
ret = convCharset("UTF-8", fsCharset, str, ret);
@ -52,7 +52,7 @@ char *fsCharsetToUtf8(char *str)
char *utf8ToFsCharset(char *str)
{
static char *ret = NULL;
static char *ret;
ret = convCharset(fsCharset, "UTF-8", str, ret);

View File

@ -137,10 +137,10 @@ void pcm_mix(char *buffer1, char *buffer2, size_t bufferSize1,
void pcm_convertAudioFormat(AudioFormat * inFormat, char *inBuffer, size_t
inSize, AudioFormat * outFormat, char *outBuffer)
{
static char *bitConvBuffer = NULL;
static int bitConvBufferLength = 0;
static char *channelConvBuffer = NULL;
static int channelConvBufferLength = 0;
static char *bitConvBuffer;
static int bitConvBufferLength;
static char *channelConvBuffer;
static int channelConvBufferLength;
char *dataChannelConv;
int dataChannelLen;
char *dataBitConv;

View File

@ -297,7 +297,7 @@ int getPlayerError(void)
char *getPlayerErrorStr(void)
{
static char *error = NULL;
static char *error;
int errorlen = MAXPATHLEN + 1024;
PlayerControl *pc = &(getPlayerData()->playerControl);
@ -504,8 +504,8 @@ void playerCycleLogFiles(void)
/* this actually creates a dupe of the current metadata */
Song *playerCurrentDecodeSong(void)
{
static Song *song = NULL;
static MetadataChunk *prev = NULL;
static Song *song;
static MetadataChunk *prev;
Song *ret = NULL;
PlayerControl *pc = &(getPlayerData()->playerControl);

View File

@ -83,9 +83,9 @@ static Playlist playlist;
static int playlist_state = PLAYLIST_STATE_STOP;
static int playlist_max_length = DEFAULT_PLAYLIST_MAX_LENGTH;
static int playlist_stopOnError;
static int playlist_errorCount = 0;
static int playlist_errorCount;
static int playlist_queueError;
static int playlist_noGoToNext = 0;
static int playlist_noGoToNext;
static int playlist_saveAbsolutePaths = DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS;
@ -1301,7 +1301,7 @@ int setPlaylistRandomStatus(int fd, int status)
int previousSongInPlaylist(int fd)
{
static time_t lastTime = 0;
static time_t lastTime;
time_t diff = time(NULL) - lastTime;
lastTime += diff;

View File

@ -320,9 +320,9 @@ int updateSongInfo(Song * song)
* we free and recreate this memory we make sure to print it correctly*/
char *getSongUrl(Song * song)
{
static char *buffer = NULL;
static int bufferSize = 0;
static Song *lastSong = NULL;
static char *buffer;
static int bufferSize;
static Song *lastSong;
int slen;
int dlen;
int size;

View File

@ -41,7 +41,7 @@ static struct _sf_cb {
{ readPlaylistState, savePlaylistState },
};
static const char *sfpath = NULL;
static const char *sfpath;
static void get_state_file_path(void)
{

View File

@ -26,15 +26,7 @@
#include <assert.h>
#include <stdlib.h>
static Tree *tagTrees[TAG_NUM_OF_ITEM_TYPES] = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
static Tree *tagTrees[TAG_NUM_OF_ITEM_TYPES];
typedef struct tagTrackerItem {
int count;

View File

@ -73,7 +73,7 @@ static int volume_ossControl = SOUND_MIXER_PCM;
#endif
#ifdef HAVE_ALSA
static snd_mixer_t *volume_alsaMixerHandle = NULL;
static snd_mixer_t *volume_alsaMixerHandle;
static snd_mixer_elem_t *volume_alsaElem;
static long volume_alsaMin;
static long volume_alsaMax;

View File

@ -46,11 +46,11 @@
#include <avahi-common/error.h>
/* Static avahi data */
static AvahiEntryGroup *avahiGroup = NULL;
static char *avahiName = NULL;
static AvahiClient* avahiClient = NULL;
static AvahiEntryGroup *avahiGroup;
static char *avahiName;
static AvahiClient* avahiClient;
static AvahiPoll avahiPoll;
static int avahiRunning = 0;
static int avahiRunning;
static int avahiFdset( fd_set* rfds, fd_set* wfds, fd_set* efds );
static int avahiFdconsume( int fdCount, fd_set* rfds, fd_set* wfds, fd_set* efds );