remove deprecated myfprintf wrapper
This shaves another 5-6k because we've removed the paranoid fflush() calls after every fprintf. Now we only fflush() when we need to git-svn-id: https://svn.musicpd.org/mpd/trunk@4493 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
71fe871908
commit
381d7232a0
@ -480,7 +480,7 @@ void saveAudioDevicesState(void)
|
||||
|
||||
assert(audioOutputArraySize != 0);
|
||||
for (i = 0; i < audioOutputArraySize; i++) {
|
||||
myfprintf(fp, AUDIO_DEVICE_STATE "%d:%s\n",
|
||||
fprintf(fp, AUDIO_DEVICE_STATE "%d:%s\n",
|
||||
(int)pdAudioDevicesEnabled[i],
|
||||
audioOutputArray[i]->name);
|
||||
}
|
||||
|
@ -267,8 +267,9 @@ void printAllOutputPluginTypes(FILE * fp)
|
||||
|
||||
while (node) {
|
||||
plugin = (AudioOutputPlugin *) node->data;
|
||||
myfprintf(fp, "%s ", plugin->name);
|
||||
fprintf(fp, "%s ", plugin->name);
|
||||
node = node->nextNode;
|
||||
}
|
||||
myfprintf(fp, "\n");
|
||||
fprintf(fp, "\n");
|
||||
fflush(fp);
|
||||
}
|
||||
|
@ -906,13 +906,13 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
|
||||
Directory *subDirectory;
|
||||
|
||||
if (directory->path) {
|
||||
myfprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
|
||||
fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
|
||||
getDirectoryPath(directory));
|
||||
}
|
||||
|
||||
while (node != NULL) {
|
||||
subDirectory = (Directory *) node->data;
|
||||
myfprintf(fp, "%s%s\n", DIRECTORY_DIR, node->key);
|
||||
fprintf(fp, "%s%s\n", DIRECTORY_DIR, node->key);
|
||||
writeDirectoryInfo(fp, subDirectory);
|
||||
node = node->nextNode;
|
||||
}
|
||||
@ -920,7 +920,7 @@ static void writeDirectoryInfo(FILE * fp, Directory * directory)
|
||||
writeSongInfoFromList(fp, directory->songs);
|
||||
|
||||
if (directory->path) {
|
||||
myfprintf(fp, "%s%s\n", DIRECTORY_END,
|
||||
fprintf(fp, "%s%s\n", DIRECTORY_END,
|
||||
getDirectoryPath(directory));
|
||||
}
|
||||
}
|
||||
@ -1106,10 +1106,10 @@ int writeDirectoryDB()
|
||||
}
|
||||
|
||||
/* block signals when writing the db so we don't get a corrupted db */
|
||||
myfprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
||||
myfprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
|
||||
myfprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, getFsCharset());
|
||||
myfprintf(fp, "%s\n", DIRECTORY_INFO_END);
|
||||
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
||||
fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
|
||||
fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, getFsCharset());
|
||||
fprintf(fp, "%s\n", DIRECTORY_INFO_END);
|
||||
|
||||
writeDirectoryInfo(fp, mp3rootDirectory);
|
||||
|
||||
|
@ -128,12 +128,13 @@ void printAllInputPluginSuffixes(FILE * fp)
|
||||
plugin = (InputPlugin *) node->data;
|
||||
suffixes = plugin->suffixes;
|
||||
while (suffixes && *suffixes) {
|
||||
myfprintf(fp, "%s ", *suffixes);
|
||||
fprintf(fp, "%s ", *suffixes);
|
||||
suffixes++;
|
||||
}
|
||||
node = node->nextNode;
|
||||
}
|
||||
myfprintf(fp, "\n");
|
||||
fprintf(fp, "\n");
|
||||
fflush(fp);
|
||||
}
|
||||
|
||||
extern InputPlugin mp3Plugin;
|
||||
|
@ -83,7 +83,7 @@ void flushWarningLog(void)
|
||||
|
||||
s = strtok(warningBuffer, "\n");
|
||||
while (s != NULL) {
|
||||
myfprintf(stderr, "%s\n", s);
|
||||
fdprintf(STDERR_FILENO, "%s\n", s);
|
||||
|
||||
s = strtok(NULL, "\n");
|
||||
}
|
||||
|
12
src/log.h
12
src/log.h
@ -23,6 +23,8 @@
|
||||
|
||||
#include "myfprintf.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_LEVEL_LOW 0
|
||||
#define LOG_LEVEL_SECURE 1
|
||||
#define LOG_LEVEL_DEBUG 2
|
||||
@ -30,18 +32,18 @@
|
||||
extern int logLevel;
|
||||
extern short warningFlushed;
|
||||
|
||||
#define ERROR(...) myfprintf(stderr, __VA_ARGS__)
|
||||
#define ERROR(...) fdprintf(STDERR_FILENO, __VA_ARGS__)
|
||||
|
||||
#define LOG(...) myfprintf(stdout, __VA_ARGS__)
|
||||
#define LOG(...) fdprintf(STDOUT_FILENO, __VA_ARGS__)
|
||||
|
||||
#define SECURE(...) if(logLevel>=LOG_LEVEL_SECURE) \
|
||||
myfprintf(stdout, __VA_ARGS__)
|
||||
fdprintf(STDOUT_FILENO, __VA_ARGS__)
|
||||
|
||||
#define DEBUG(...) if(logLevel>=LOG_LEVEL_DEBUG) \
|
||||
myfprintf(stdout, __VA_ARGS__)
|
||||
fdprintf(STDOUT_FILENO, __VA_ARGS__)
|
||||
|
||||
#define WARNING(...) { \
|
||||
if(warningFlushed) myfprintf(stderr, __VA_ARGS__); \
|
||||
if(warningFlushed) fdprintf(STDERR_FILENO, __VA_ARGS__); \
|
||||
else bufferWarning(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,8 @@ static void parseOptions(int argc, char **argv, Options * options)
|
||||
version();
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
myfprintf(stderr,
|
||||
"unknown command line option: %s\n",
|
||||
fprintf(stderr,
|
||||
"unknown command line option: %s\n",
|
||||
argv[i]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -447,13 +447,13 @@ static void setupLogOutput(Options * options, FILE * out, FILE * err)
|
||||
fflush(NULL);
|
||||
|
||||
if (dup2(fileno(out), STDOUT_FILENO) < 0) {
|
||||
myfprintf(err, "problems dup2 stdout : %s\n",
|
||||
fprintf(err, "problems dup2 stdout : %s\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (dup2(fileno(err), STDERR_FILENO) < 0) {
|
||||
myfprintf(err, "problems dup2 stderr : %s\n",
|
||||
fprintf(err, "problems dup2 stderr : %s\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -30,11 +30,6 @@ void myfprintfStdLogMode(FILE * out, FILE * err);
|
||||
mpd_fprintf void fdprintf(const int fd, const char *fmt, ...);
|
||||
void vfdprintf(const int fd, const char *fmt, va_list arglist);
|
||||
|
||||
#define myfprintf(fp, ...) do { \
|
||||
fprintf(fp, __VA_ARGS__); \
|
||||
fflush(fp); \
|
||||
} while (0)
|
||||
|
||||
int myfprintfCloseAndOpenLogFile();
|
||||
|
||||
void myfprintfCloseLogFile();
|
||||
|
@ -270,36 +270,37 @@ void savePlaylistState(void)
|
||||
return;
|
||||
}
|
||||
|
||||
myfprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
|
||||
fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
|
||||
switch (playlist_state) {
|
||||
case PLAYLIST_STATE_PLAY:
|
||||
switch (getPlayerState()) {
|
||||
case PLAYER_STATE_PAUSE:
|
||||
myfprintf(fp, "%s\n",
|
||||
fprintf(fp, "%s\n",
|
||||
PLAYLIST_STATE_FILE_STATE_PAUSE);
|
||||
break;
|
||||
default:
|
||||
myfprintf(fp, "%s\n",
|
||||
fprintf(fp, "%s\n",
|
||||
PLAYLIST_STATE_FILE_STATE_PLAY);
|
||||
}
|
||||
myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT,
|
||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT,
|
||||
playlist.order[playlist.current]);
|
||||
myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME,
|
||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME,
|
||||
getPlayerElapsedTime());
|
||||
break;
|
||||
default:
|
||||
myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP);
|
||||
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP);
|
||||
break;
|
||||
}
|
||||
myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM,
|
||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM,
|
||||
playlist.random);
|
||||
myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT,
|
||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT,
|
||||
playlist.repeat);
|
||||
myfprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
|
||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
|
||||
(int)(getPlayerCrossFade()));
|
||||
myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
|
||||
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
|
||||
fflush(fp);
|
||||
showPlaylist(fileno(fp));
|
||||
myfprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
|
||||
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
|
||||
|
||||
while (fclose(fp) && errno == EINTR) ;
|
||||
}
|
||||
@ -1414,12 +1415,12 @@ int savePlaylist(int fd, char *utf8file)
|
||||
for (i = 0; i < playlist.length; i++) {
|
||||
if (playlist_saveAbsolutePaths &&
|
||||
playlist.songs[i]->type == SONG_TYPE_FILE) {
|
||||
myfprintf(fileP, "%s\n",
|
||||
fprintf(fileP, "%s\n",
|
||||
rmp2amp(utf8ToFsCharset
|
||||
((getSongUrl(playlist.songs[i])))));
|
||||
} else {
|
||||
url = utf8ToFsCharset(getSongUrl(playlist.songs[i]));
|
||||
myfprintf(fileP, "%s\n", url);
|
||||
fprintf(fileP, "%s\n", url);
|
||||
free(url);
|
||||
|
||||
}
|
||||
|
@ -170,17 +170,18 @@ void writeSongInfoFromList(FILE * fp, SongList * list)
|
||||
{
|
||||
ListNode *tempNode = list->firstNode;
|
||||
|
||||
myfprintf(fp, "%s\n", SONG_BEGIN);
|
||||
fprintf(fp, "%s\n", SONG_BEGIN);
|
||||
|
||||
while (tempNode != NULL) {
|
||||
myfprintf(fp, "%s%s\n", SONG_KEY, tempNode->key);
|
||||
fprintf(fp, "%s%s\n", SONG_KEY, tempNode->key);
|
||||
fflush(fp);
|
||||
printSongInfo(fileno(fp), (Song *) tempNode->data);
|
||||
myfprintf(fp, "%s%li\n", SONG_MTIME,
|
||||
fprintf(fp, "%s%li\n", SONG_MTIME,
|
||||
(long)((Song *) tempNode->data)->mtime);
|
||||
tempNode = tempNode->nextNode;
|
||||
}
|
||||
|
||||
myfprintf(fp, "%s\n", SONG_END);
|
||||
fprintf(fp, "%s\n", SONG_END);
|
||||
}
|
||||
|
||||
static void insertSongIntoList(SongList * list, ListNode ** nextSongNode,
|
||||
|
Loading…
Reference in New Issue
Block a user