From 5ddb41da85cb3e3b29ae4195b3a7c27296bb0d38 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 6 Feb 2020 01:50:45 +0000 Subject: [PATCH] 20 compiler warning fixes --- boxstack.cc | 7 +++---- dsock.cc | 33 ++++++++++++++------------------- vconnect.cc | 2 +- vepg.cc | 3 +-- vmute.cc | 5 ++--- vrecordinglist.cc | 5 ++--- vrecordingmenu.cc | 2 ++ vsleeptimer.cc | 4 ++-- vvideolivetv.cc | 1 + vvideorec.cc | 6 +++--- vvolume.cc | 5 ++--- vwelcome.cc | 5 ++--- 12 files changed, 35 insertions(+), 43 deletions(-) diff --git a/boxstack.cc b/boxstack.cc index 0c477d4..69345a0 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "boxstack.h" @@ -587,12 +586,12 @@ void BoxStack::processMessage(Message* m) { case Message::CLOSE_ME: { - remove((Boxx*)m->from); + remove(static_cast(m->from)); break; } case Message::ADD_VIEW: { - Boxx* toAdd = (Boxx*)m->parameter; + Boxx* toAdd = reinterpret_cast(m->parameter); add(toAdd); toAdd->draw(); update(toAdd); diff --git a/dsock.cc b/dsock.cc index ec793b5..ebc41db 100644 --- a/dsock.cc +++ b/dsock.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "dsock.h" @@ -45,7 +44,7 @@ int DatagramSocket::init() myAddr.sin_addr.s_addr = getIPNumber(iterate_ip++); // auto-fill with my IP memset(&(myAddr.sin_zero), 0, 8); // zero the rest of the struct - if (bind(socketnum, (struct sockaddr *)&myAddr, addrlen) == -1) + if (bind(socketnum, reinterpret_cast(&myAddr), addrlen) == -1) { perror("bind"); return 0; } FD_ZERO(&readfds); @@ -54,7 +53,7 @@ int DatagramSocket::init() tv.tv_usec = 0; int allowed = 1; - setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, (char*)&allowed, sizeof(allowed)); + setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, static_cast(&allowed), sizeof(allowed)); initted = true; @@ -106,7 +105,7 @@ unsigned char DatagramSocket::waitforMessage(unsigned char how) { return 1; } if ((mlength = recvfrom(socketnum, buf, MAXBUFLEN, 0, - (struct sockaddr *)&theirAddr, &addrlen)) == -1) + reinterpret_cast(&theirAddr), &addrlen)) == -1) { perror("recvfrom"); return 0; } else { @@ -119,7 +118,7 @@ unsigned char DatagramSocket::waitforMessage(unsigned char how) //printf("%s:%i\tIN %i\t", fromIPA, fromPort, mlength); int k; for(k = 0; k < mlength; k++) - printf("%u ", (unsigned char)buf[k]); + printf("%u ", static_cast(buf[k])); printf("\n"); } return 2; @@ -150,7 +149,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length int k; UCHAR l; for (k = 0; k < length; k++) - { l = (UCHAR)message[k]; printf("%u ", l); } + { l = static_cast(message[k]); printf("%u ", l); } } int sentLength = 0; @@ -164,7 +163,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length errno = 0; - sentLength = sendto(socketnum, message, length, 0, (struct sockaddr *)&theirAddr, addrlen); + sentLength = sendto(socketnum, message, length, 0, reinterpret_cast(&theirAddr), addrlen); if (sentLength == length) { if (DSOCKDEBUG) printf(" GOOD\n"); @@ -175,7 +174,7 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length { printf(" --BAD--"); fflush(stdout); } - sentLength = sendto(socketnum, message, length, 0, (struct sockaddr *)&theirAddr, addrlen); + sentLength = sendto(socketnum, message, length, 0, reinterpret_cast(&theirAddr), addrlen); if (sentLength == length) { if (DSOCKDEBUG) printf(" GOOD\n"); @@ -203,17 +202,14 @@ void DatagramSocket::send(const char *ipa, short port, char *message, int length } } -ULONG DatagramSocket::getIPNumber(ULONG num) -{ #ifndef WIN32 +ULONG DatagramSocket::getIPNumber(ULONG) +{ return INADDR_ANY; - - // gcc 3.4 says: - // warning: Using 'gethostbyname' in statically linked applications requires at runtime - // the shared libraries from the glibc version used for linking - +} #else - +ULONG DatagramSocket::getIPNumber(ULONG num) +{ char buffer[100]; ULONG returnaddress; @@ -234,6 +230,5 @@ ULONG DatagramSocket::getIPNumber(ULONG num) int get_ip=(num%num_ip);//Just wrap around, if no interface are present any more memcpy(&returnaddress, hosts->h_addr_list[get_ip], sizeof(ULONG)); return returnaddress; - -#endif } +#endif diff --git a/vconnect.cc b/vconnect.cc index e5c70cc..6982c75 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -65,7 +65,7 @@ void VConnect::draw() logger->log("VConnect", Log::DEBUG, "Draw done"); } -int VConnect::handleCommand(int command) +int VConnect::handleCommand(int /* command */) { return 1; } diff --git a/vepg.cc b/vepg.cc index 5354e73..fe338a7 100644 --- a/vepg.cc +++ b/vepg.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ /* vepg presents a 2 dimensional electronic programme guide with channels down diff --git a/vmute.cc b/vmute.cc index a554b9a..3691253 100644 --- a/vmute.cc +++ b/vmute.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "vmute.h" @@ -66,7 +65,7 @@ void VMute::draw() Timers::getInstance()->setTimerD(this, 1, 2); } -void VMute::timercall(int clientReference) +void VMute::timercall(int /* clientReference */) { // delete me! Message* m = new Message(); // Delete self diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 9331cb6..f5a66ad 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "vrecordinglist.h" @@ -88,7 +87,7 @@ void VRecordingList::processMessage(Message* m) else if (m->message == Message::MOVE_RECORDING) { Log::getInstance()->log("VRecordingList", Log::DEBUG, "Doing move recording"); - doMoveRecording((Directory*)m->parameter); + doMoveRecording(reinterpret_cast(m->parameter)); } else if (m->message == Message::PLAY_SELECTED_RECORDING) { diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 49307d0..1af32d8 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -182,6 +182,8 @@ int VRecordingMenu::handleCommand(int command) BoxStack::getInstance()->update(v); return 2; } + + [[fallthrough]]; // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy } case Remote::BACK: { diff --git a/vsleeptimer.cc b/vsleeptimer.cc index e1f1814..85c3872 100644 --- a/vsleeptimer.cc +++ b/vsleeptimer.cc @@ -161,7 +161,7 @@ void Sleeptimer::threadMethod() Message* m1 = new Message(); m1->message = Message::ADD_VIEW; m1->to = BoxStack::getInstance(); - m1->parameter = (ULONG)count; + m1->parameter = reinterpret_cast(count); MessageQueue::getInstance()->postMessage(m1); } MILLISLEEP(1000); @@ -224,7 +224,7 @@ void VSleeptimer::draw() Timers::getInstance()->setTimerD(this, 1, 2); } -void VSleeptimer::timercall(int clientReference) +void VSleeptimer::timercall(int /* clientReference */) { // delete me! Message* m = new Message(); // Delete self diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 8f05b06..48a5b71 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -313,6 +313,7 @@ int VVideoLiveTV::handleCommand(int command) } // else drop through to stop } + [[fallthrough]]; case Remote::STOP: { stop(); diff --git a/vvideorec.cc b/vvideorec.cc index 12650ab..5b15739 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include @@ -246,7 +245,8 @@ int VVideoRec::handleCommand(int command) removeSummary(); return 2; } - } // DROP THROUGH + } + [[fallthrough]]; case Remote::STOP: case Remote::MENU: { diff --git a/vvolume.cc b/vvolume.cc index 9c05d62..bf9dce1 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "vvolume.h" @@ -82,7 +81,7 @@ void VVolume::draw() Timers::getInstance()->setTimerD(this, 1, 2); } -void VVolume::timercall(int clientReference) +void VVolume::timercall(int /* clientReference */) { // delete me! Message* m = new Message(); // Delete self diff --git a/vwelcome.cc b/vwelcome.cc index d995e4a..5ce34fd 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "vwelcome.h" @@ -174,7 +173,7 @@ void VWelcome::drawClock() Timers::getInstance()->setTimerT(this, 1, dt); } -void VWelcome::timercall(int clientReference) +void VWelcome::timercall(int /* clientReference */) { #ifndef GRADIENT_DRAWING drawClock(); -- 2.39.2