Permalink
Browse files

Fix gsmlib namespace

  • Loading branch information...
1 parent d6f91cd commit c5751f609453f7d6dff7d385ca177f077c48c5ba @gierschv gierschv committed Sep 4, 2011
Showing with 10 additions and 4 deletions.
  1. +9 −3 gsmlib/gsm_sorted_sms_store.cc
  2. +1 −1 gsmlib/gsm_unix_serial.cc
@@ -18,6 +18,7 @@
#include <gsmlib/gsm_sorted_sms_store.h>
#include <iostream>
#include <fstream>
+#include <cstring>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -81,8 +82,10 @@ void SortedSMSStore::readSMSFile(std::istream &pbs, std::string filename)
{
// ignore error, file might be empty initially
}
- unsigned_int_2 version = ntohs(*((unsigned_int_2*)numberBuf));
- if (! pbs.eof() && version != SMS_STORE_FILE_FORMAT_VERSION)
+ unsigned_int_2 version;
+ memcpy(&version, numberBuf, sizeof(*numberBuf));
+ version = ntohs(version);
+ if (!pbs.eof() && version != SMS_STORE_FILE_FORMAT_VERSION)
throw GsmException(stringPrintf(_("file '%s' has wrong version"),
filename.c_str()), ParameterError);
@@ -93,7 +96,10 @@ void SortedSMSStore::readSMSFile(std::istream &pbs, std::string filename)
if (! readnbytes(filename, pbs, 2, numberBuf, false))
break;
- unsigned_int_2 pduLen = ntohs(*((unsigned_int_2*)numberBuf));
+ unsigned_int_2 pduLen;
+ memcpy(&pduLen, numberBuf, sizeof(*numberBuf));
+ pduLen = ntohs(pduLen);
+
if (pduLen > 500)
throw GsmException(stringPrintf(_("corrupt SMS store file '%s'"),
filename.c_str()), ParameterError);
@@ -414,7 +414,7 @@ UnixSerialPort::~UnixSerialPort()
close(_fd);
}
-speed_t baudRateStrToSpeed(std::string baudrate) throw(GsmException)
+speed_t gsmlib::baudRateStrToSpeed(std::string baudrate) throw(GsmException)
{
if (baudrate == "300")
return B300;

0 comments on commit c5751f6

Please sign in to comment.