From ce28b4a9ea58a5f220029a793a6cbf2555d4fdf0 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Wed, 25 Feb 2004 16:13:37 +0000 Subject: [PATCH] More -Wall cleanups --- src/main.c | 1 + src/mdns/mDNS.c | 5 +- src/mdns/mDNSPosix.c | 10 +-- src/mp3-scanner.c | 2 - src/parser.y | 1 + src/rend-posix.c | 148 ++----------------------------------------- 6 files changed, 12 insertions(+), 155 deletions(-) diff --git a/src/main.c b/src/main.c index 09a2882e..12a52d5e 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include diff --git a/src/mdns/mDNS.c b/src/mdns/mDNS.c index 6bf8f758..d11131ec 100644 --- a/src/mdns/mDNS.c +++ b/src/mdns/mDNS.c @@ -68,6 +68,9 @@ Change History (most recent first): $Log$ +Revision 1.2 2004/02/25 16:13:37 rpedde +More -Wall cleanups + Revision 1.1 2003/10/23 21:43:01 ron Add Apple mDNS reponder @@ -3782,7 +3785,6 @@ mDNSexport void mDNS_GenerateFQDN(mDNS *const m) mDNSlocal void HostNameCallback(mDNS *const m, ResourceRecord *const rr, mStatus result) { - #pragma unused(rr) switch (result) { case mStatus_NoError: @@ -3939,7 +3941,6 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se mDNSlocal void ServiceCallback(mDNS *const m, ResourceRecord *const rr, mStatus result) { - #pragma unused(m) ServiceRecordSet *sr = (ServiceRecordSet *)rr->Context; switch (result) { diff --git a/src/mdns/mDNSPosix.c b/src/mdns/mDNSPosix.c index f1cb2363..165aa712 100755 --- a/src/mdns/mDNSPosix.c +++ b/src/mdns/mDNSPosix.c @@ -22,6 +22,9 @@ Change History (most recent first): $Log$ +Revision 1.3 2004/02/25 16:13:37 rpedde +More -Wall cleanups + Revision 1.2 2003/11/26 06:12:53 ron Exclude from memory checks @@ -121,8 +124,6 @@ static mStatus PosixErrorToStatus(int errNum) return result; } -#pragma mark ***** Send and Receive - mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end, mDNSIPAddr src, mDNSIPPort srcPort, mDNSIPAddr dst, mDNSIPPort dstPort) // mDNS core calls this routine when it needs to send a packet. @@ -256,7 +257,6 @@ static void SocketDataReady(mDNS *const m, PosixNetworkInterface *intf, int skt) } } -#pragma mark ***** Init and Term // On OS X this gets the text of the field labelled "Computer Name" in the Sharing Prefs Control Panel // Other platforms can either get the information from the appropriate place, @@ -723,7 +723,6 @@ extern mStatus mDNSPlatformPosixRefreshInterfaceList(mDNS *const m) return PosixErrorToStatus(err); } -#pragma mark ***** Locking // On the Posix platform, locking is a no-op because we only ever enter // mDNS core on the main thread. @@ -732,7 +731,6 @@ mDNSexport void mDNSPlatformLock (const mDNS *const m) // mDNS core calls this routine when it wants to prevent // the platform from reentering mDNS core code. { - #pragma unused(m) } mDNSexport void mDNSPlatformUnlock (const mDNS *const m) @@ -740,10 +738,8 @@ mDNSexport void mDNSPlatformUnlock (const mDNS *const m) // taken by mDNSPlatformLock and allow the platform to // reenter mDNS core code. { - #pragma unused(m) } -#pragma mark ***** Strings mDNSexport void mDNSPlatformStrCopy(const void *src, void *dst) // mDNS core calls this routine to copy C strings. diff --git a/src/mp3-scanner.c b/src/mp3-scanner.c index c2f8be9a..ee79c325 100644 --- a/src/mp3-scanner.c +++ b/src/mp3-scanner.c @@ -271,8 +271,6 @@ int scan_foreground(char *path) { struct dirent *pde; int err; char mp3_path[PATH_MAX]; - char linebuffer[PATH_MAX]; - int fd; struct stat sb; if((current_dir=opendir(path)) == NULL) { diff --git a/src/parser.y b/src/parser.y index 141fdd69..7a1393e3 100644 --- a/src/parser.y +++ b/src/parser.y @@ -24,6 +24,7 @@ #include +#include #include "playlist.h" #define YYERROR_VERBOSE 1 diff --git a/src/rend-posix.c b/src/rend-posix.c index 1ff0fb32..6a24b4bc 100644 --- a/src/rend-posix.c +++ b/src/rend-posix.c @@ -89,6 +89,9 @@ Change History (most recent first): $Log$ + Revision 1.12 2004/02/25 16:13:37 rpedde + More -Wall cleanups + Revision 1.11 2004/02/09 18:33:59 rpedde Pretty up @@ -151,16 +154,15 @@ #include #define __IN_ERR__ +#include "daapd.h" #include "err.h" #include "rend.h" #include "rend-unix.h" -#pragma mark ***** Globals static mDNS mDNSStorage; // mDNS core uses this to store its globals static mDNS_PlatformSupport PlatformStorage; // Stores this platform's globals -#pragma mark ***** Signals static volatile mDNSBool gStopNow; @@ -202,140 +204,8 @@ static void HandleSigQuit(int sigraised) exit(0); } -#pragma mark ***** Parameter Checking -static mDNSBool CheckThatRichTextHostNameIsUsable(const char *richTextHostName) -// Checks that richTextHostName is a reasonable host name -// label and, if it isn't and printExplanation is true, prints -// an explanation of why not. -{ - mDNSBool result; - domainlabel richLabel; - domainlabel poorLabel; - - result = mDNStrue; - if (result && strlen(richTextHostName) > 63) { - result = mDNSfalse; - } - if (result && richTextHostName[0] == 0) { - result = mDNSfalse; - } - if (result) { - ConvertCStringToDomainLabel(richTextHostName, &richLabel); - ConvertUTF8PstringToRFC1034HostLabel(richLabel.c, &poorLabel); - if (poorLabel.c[0] == 0) { - result = mDNSfalse; - } - } - return result; -} -static mDNSBool CheckThatServiceTypeIsUsable(const char *serviceType) -// Checks that serviceType is a reasonable service type -// label and, if it isn't and printExplanation is true, prints -// an explanation of why not. -{ - mDNSBool result; - - result = mDNStrue; - if (result && strlen(serviceType) > 63) { - result = mDNSfalse; - } - if (result && serviceType[0] == 0) { - result = mDNSfalse; - } - return result; -} - -static mDNSBool CheckThatServiceTextIsUsable(const char *serviceText, - mDNSu8 *pStringList, mDNSu16 *pStringListLen) -// Checks that serviceText is a reasonable service text record -// and, if it isn't and printExplanation is true, prints -// an explanation of why not. Also parse the text into -// the packed PString buffer denoted by pStringList and -// return the length of that buffer in *pStringListLen. -// Note that this routine assumes that the buffer is -// sizeof(RDataBody) bytes long. -{ - mDNSBool result; - size_t serviceTextLen; - - // Note that parsing a C string into a PString list always - // expands the data by one character, so the following - // compare is ">=", not ">". Here's the logic: - // - // #1 For a string with not ^A's, the PString length is one - // greater than the C string length because we add a length - // byte. - // #2 For every regular (not ^A) character you add to the C - // string, you add a regular character to the PString list. - // This does not affect the equivalence stated in #1. - // #3 For every ^A you add to the C string, you add a length - // byte to the PString list but you also eliminate the ^A, - // which again does not affect the equivalence stated in #1. - - result = mDNStrue; - serviceTextLen = strlen(serviceText); - if (result && strlen(serviceText) >= sizeof(RDataBody)) { - result = mDNSfalse; - } - - // Now break the string up into PStrings delimited by ^A. - // We know the data will fit so we can ignore buffer overrun concerns. - // However, we still have to treat runs long than 255 characters as - // an error. - - if (result) { - int lastPStringOffset; - int i; - int thisPStringLen; - - // This algorithm is a little tricky. We start by copying - // the string directly into the output buffer, shifted up by - // one byte. We then fill in the first byte with a ^A. - // We then walk backwards through the buffer and, for each - // ^A that we find, we replace it with the difference between - // its offset and the offset of the last ^A that we found - // (ie lastPStringOffset). - - memcpy(&pStringList[1], serviceText, serviceTextLen); - pStringList[0] = 1; - lastPStringOffset = serviceTextLen + 1; - for (i = serviceTextLen; i >= 0; i--) { - if ( pStringList[i] == 1 ) { - thisPStringLen = (lastPStringOffset - i - 1); - assert(thisPStringLen >= 0); - if (thisPStringLen > 255) { - result = mDNSfalse; - break; - } else { - pStringList[i] = thisPStringLen; - lastPStringOffset = i; - } - } - } - - *pStringListLen = serviceTextLen + 1; - } - - return result; -} - -static mDNSBool CheckThatPortNumberIsUsable(long portNumber) -// Checks that portNumber is a reasonable port number -// and, if it isn't and printExplanation is true, prints -// an explanation of why not. -{ - mDNSBool result; - - result = mDNStrue; - if (result && (portNumber <= 0 || portNumber > 65535)) { - result = mDNSfalse; - } - return result; -} - -#pragma mark ***** Command Line Arguments /* get rid of pidfile handling - rep - 21 Oct 2k3 */ static const char kDefaultServiceType[] = "_http._tcp."; @@ -343,15 +213,6 @@ enum { kDefaultPortNumber = 80 }; -static mDNSBool gAvoidPort53 = mDNStrue; -static const char *gRichTextHostName = ""; -static const char *gServiceType = kDefaultServiceType; -static mDNSu8 gServiceText[sizeof(RDataBody)]; -static mDNSu16 gServiceTextLen = 0; -static int gPortNumber = kDefaultPortNumber; - -#pragma mark ***** Registration - typedef struct PosixService PosixService; struct PosixService { @@ -540,7 +401,6 @@ void rend_callback(void) { } -#pragma mark **** rend_private_init int rend_private_init(char *user) { mStatus status;