From 73cbde8fc8e40311247bc3c3717c53919a88baba Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 2 Jun 2012 17:23:07 +0100 Subject: [PATCH] Fix all compiler warnings --- Makefile | 4 ++-- mvpreceiver.c | 18 ++++++++++-------- mvprelay.c | 7 +++++-- recplayer.c | 3 +++ tftpclient.c | 5 +++-- vompclient.c | 5 +++-- vompclientrrproc.c | 35 +++++++++++++++++------------------ 7 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index aa81064..31b3bca 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ pri CXX ?= g++ ifdef DEBUG -CXXFLAGS ?= -g -Wall -Woverloaded-virtual -Wno-parentheses #-Werror +CXXFLAGS ?= -g -Wall -Woverloaded-virtual -Wno-parentheses -Werror else -CXXFLAGS ?= -O2 -Wall -Woverloaded-virtual -Wno-parentheses #-Werror +CXXFLAGS ?= -O2 -Wall -Woverloaded-virtual -Wno-parentheses -Werror endif ### The directory environment: diff --git a/mvpreceiver.c b/mvpreceiver.c index 49028b5..b27d8c9 100644 --- a/mvpreceiver.c +++ b/mvpreceiver.c @@ -116,6 +116,7 @@ void MVPReceiver::Receive(UCHAR* data, int length) void MVPReceiver::threadMethod() { + ULONG *p; ULONG headerLength = sizeof(ULONG) * 4; UCHAR buffer[streamChunkSize + headerLength]; int amountReceived; @@ -135,10 +136,10 @@ void MVPReceiver::threadMethod() amountReceived = processed.get(buffer+headerLength, streamChunkSize); pthread_mutex_unlock(&processedRingLock); - *(ULONG*)&buffer[0] = htonl(2); // stream channel - *(ULONG*)&buffer[4] = htonl(streamID); - *(ULONG*)&buffer[8] = htonl(0); // here insert flag: 0 = ok, data follows - *(ULONG*)&buffer[12] = htonl(amountReceived); + p = (ULONG*)&buffer[0]; *p = htonl(2); // stream channel + p = (ULONG*)&buffer[4]; *p = htonl(streamID); + p = (ULONG*)&buffer[8]; *p = htonl(0); // here insert flag: 0 = ok, data follows + p = (ULONG*)&buffer[12]; *p = htonl(amountReceived); tcp->sendPacket(buffer, amountReceived + headerLength); } while(processed.getContent() >= streamChunkSize); @@ -147,12 +148,13 @@ void MVPReceiver::threadMethod() void MVPReceiver::sendStreamEnd() { + ULONG *p; ULONG bufferLength = sizeof(ULONG) * 4; UCHAR buffer[bufferLength]; - *(ULONG*)&buffer[0] = htonl(2); // stream channel - *(ULONG*)&buffer[4] = htonl(streamID); - *(ULONG*)&buffer[8] = htonl(1); // stream end - *(ULONG*)&buffer[12] = htonl(0); // zero length, no more data + p = (ULONG*)&buffer[0]; *p = htonl(2); // stream channel + p = (ULONG*)&buffer[4]; *p = htonl(streamID); + p = (ULONG*)&buffer[8]; *p = htonl(1); // stream end + p = (ULONG*)&buffer[12]; *p = htonl(0); // zero length, no more data tcp->sendPacket(buffer, bufferLength); } diff --git a/mvprelay.c b/mvprelay.c index d266674..3dd45f1 100644 --- a/mvprelay.c +++ b/mvprelay.c @@ -95,6 +95,7 @@ void MVPRelay::threadMethod() // Construct reply packet + ULONG* p; UCHAR out[52]; memset(out, 0, 52); @@ -102,13 +103,15 @@ void MVPRelay::threadMethod() memcpy(out, in, 4); // Return magic number is 0xfafebabe - *(ULONG*)&out[4] = htonl(0xfafebabe); + p = (ULONG*)&out[4]; + *p = htonl(0xfafebabe); // Copy client IP and port to reply memcpy(&out[16], &in[16], 6); // Insert server address - *(ULONG*)&out[24] = myIP; + p = (ULONG*)&out[24]; + *p = myIP; // Send it ds.send(ds.getFromIPA(), peerPort, (char*)out, 52); diff --git a/recplayer.c b/recplayer.c index 82c056d..9fac759 100644 --- a/recplayer.c +++ b/recplayer.c @@ -20,7 +20,10 @@ #include "recplayer.h" +#ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 +#endif + #include RecPlayer::RecPlayer(cRecording* rec) diff --git a/tftpclient.c b/tftpclient.c index 8dec41a..58d305f 100644 --- a/tftpclient.c +++ b/tftpclient.c @@ -290,8 +290,9 @@ int TftpClient::openFile(char* requestedFile) int TftpClient::sendBlock() { - *(USHORT*)&buffer[0] = htons(3); - *(USHORT*)&buffer[2] = htons(blockNumber++); + USHORT* p; + p = (USHORT*)&buffer[0]; *p = htons(3); + p = (USHORT*)&buffer[2]; *p = htons(blockNumber++); bufferLength = 4 + fread(&buffer[4], 1, 512, file); if (bufferLength < 516) // 512 + 4 header diff --git a/vompclient.c b/vompclient.c index 64fd20b..25dc541 100644 --- a/vompclient.c +++ b/vompclient.c @@ -318,9 +318,10 @@ void VompClient::run2() log->log("Client", Log::DEBUG, "Received chan=%lu kats=%lu", channelID, kaTimeStamp); + ULONG* p; UCHAR buffer[8]; - *(ULONG*)&buffer[0] = htonl(3); // KA CHANNEL - *(ULONG*)&buffer[4] = htonl(kaTimeStamp); + p = (ULONG*)&buffer[0]; *p = htonl(3); // KA CHANNEL + p = (ULONG*)&buffer[4]; *p = htonl(kaTimeStamp); if (!tcp.sendPacket(buffer, 8)) { log->log("Client", Log::ERR, "Could not send back KA reply"); diff --git a/vompclientrrproc.c b/vompclientrrproc.c index 44e7bd4..3d1bf08 100644 --- a/vompclientrrproc.c +++ b/vompclientrrproc.c @@ -262,15 +262,14 @@ bool VompClientRRProc::processPacket() result = processGetLanguageContent(); break; case VDR_GETMEDIAINFO: - result= processGetMediaInfo(); - break; + result = processGetMediaInfo(); + break; case VDR_CLOSECHANNEL: - result= processCloseMediaChannel(); - break; + result = processCloseMediaChannel(); + break; case 37: result = processSetCharset(); break; - } delete resp; @@ -314,23 +313,23 @@ int VompClientRRProc::processLogin() int VompClientRRProc::processSetCharset() { - int charset = ntohl(*(ULONG*)req->data); - if (charset>0 && charset<3) { - log->log("RRProc", Log::DEBUG, "Set charset to %d", charset); - x.setCharset(charset); - resp->addULONG(1); - } else { - log->log("RRProc", Log::DEBUG, "Invalid charset %d", charset); - resp->addULONG(0); - } + int charset = ntohl(*(ULONG*)req->data); + if (charset>0 && charset<3) + { + log->log("RRProc", Log::DEBUG, "Set charset to %d", charset); + x.setCharset(charset); + resp->addULONG(1); + } + else + { + log->log("RRProc", Log::DEBUG, "Invalid charset %d", charset); + resp->addULONG(0); + } resp->finalise(); x.tcp.sendPacket(resp->getPtr(), resp->getLen()); - + return 1; } - - - int VompClientRRProc::processConfigSave() { char* section = (char*)req->data; -- 2.39.5