More -Wall cleanups

This commit is contained in:
Ron Pedde 2004-02-25 16:13:37 +00:00
parent a6572b3f34
commit ce28b4a9ea
6 changed files with 12 additions and 155 deletions

View File

@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <limits.h>
#include <pthread.h>
#include <pwd.h>

View File

@ -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)
{

View File

@ -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.

View File

@ -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) {

View File

@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "playlist.h"
#define YYERROR_VERBOSE 1

View File

@ -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 <sys/types.h>
#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;