[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10595: Merge compiler warning fixes
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10595: Merge compiler warning fixes from 0.8.5 branch. |
Date: |
Thu, 19 Feb 2009 13:40:31 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10595
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-02-19 13:40:31 +0100
message:
Merge compiler warning fixes from 0.8.5 branch.
modified:
libamf/amf.cpp
libamf/buffer.cpp
libamf/element.cpp
libnet/http.cpp
libnet/network.cpp
libnet/rtmp.cpp
libnet/rtmp.h
------------------------------------------------------------
revno: 10592.2.1
committer: Benjamin Wolsey <address@hidden>
branch nick: release_0_8_5
timestamp: Thu 2009-02-19 10:17:14 +0100
message:
Fix warnings, use typedefs and a function object for clarity. Add
assertion
to make sure memory won't be silently corrupted and to make programme
logic
clear.
modified:
libamf/amf.cpp
libamf/buffer.cpp
libamf/element.cpp
libnet/http.cpp
libnet/network.cpp
libnet/rtmp.cpp
libnet/rtmp.h
------------------------------------------------------------
revno: 10592.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: release_0_8_5
timestamp: Thu 2009-02-19 10:59:48 +0100
message:
Silence compiler warnings for unused variables. Use boost format or
stringstreams to avoid problems with different size size_t. Fix
uninitialized values and absent return value.
modified:
libamf/amf.cpp
libamf/buffer.cpp
libamf/element.cpp
libnet/http.cpp
libnet/network.cpp
libnet/rtmp.cpp
libnet/rtmp.h
=== modified file 'libamf/amf.cpp'
--- a/libamf/amf.cpp 2009-02-17 00:59:30 +0000
+++ b/libamf/amf.cpp 2009-02-19 09:17:14 +0000
@@ -431,7 +431,7 @@
// GNASH_REPORT_FUNCTION;
boost::uint32_t length;
bool sparse = false;
- size_t counter = 0;
+ //size_t counter = 0;
length = data.propertySize();
// log_debug("Encoded data size has %d properties", length);
@@ -580,9 +580,9 @@
} else {
if (sparse) {
sparse = false;
- char num[12];
- sprintf(num, "%d", counter);
- amf::Element elnum(num, el->to_number());
+ std::ostringstream os;
+ os << counter;
+ amf::Element elnum(os.str().c_str(), el->to_number());
*buf += AMF::encodeElement(elnum);
double nodes = items;
amf::Element ellen("length", nodes);
=== modified file 'libamf/buffer.cpp'
--- a/libamf/buffer.cpp 2009-02-17 03:18:15 +0000
+++ b/libamf/buffer.cpp 2009-02-19 09:17:14 +0000
@@ -205,14 +205,10 @@
std::copy(data, data + nbytes, _data.get());
_seekptr = _data.get() + nbytes;
} else {
- char num[12];
- sprintf(num, "%d", nbytes);
- string msg = "Not enough storage was allocated to hold the copied data!
Needs ";
- msg += num;
- msg += " only has ";
- sprintf(num, "%d", _nbytes);
- msg += num;
- throw GnashException(msg);
+ boost::format msg("Not enough storage was allocated to hold the "
+ "copied data! Needs %1%, only has %2% bytes");
+ msg % nbytes % _nbytes;
+ throw GnashException(msg.str());
}
return *this;
}
@@ -234,14 +230,10 @@
std::copy(data, data + nbytes, _seekptr);
_seekptr += nbytes;
} else {
- char num[12];
- string msg = "Not enough storage was allocated to hold the appended
data! Needs ";
- sprintf(num, "%d", nbytes);
- msg += num;
- msg += " only has ";
- sprintf(num, "%d", _nbytes - allocated());
- msg += num;
- throw GnashException(msg);
+ boost::format msg("Not enough storage was allocated to hold the "
+ "appended data! Needs %1%, only has %2% bytes");
+ msg % nbytes % _nbytes;
+ throw GnashException(msg.str());
}
}
@@ -755,7 +747,7 @@
int
Buffer::corrupt()
{
- corrupt(10);
+ return corrupt(10);
}
int
=== modified file 'libamf/element.cpp'
--- a/libamf/element.cpp 2009-02-11 09:27:20 +0000
+++ b/libamf/element.cpp 2009-02-19 09:17:14 +0000
@@ -1294,7 +1294,7 @@
Element &
Element::makeUnsupported(boost::uint8_t *data)
{
-// GNASH_REPORT_FUNCTION;
+ UNUSED(data);
_type = Element::UNSUPPORTED_AMF0;
return *this;
}
@@ -1320,7 +1320,7 @@
Element &
Element::makeLongString(boost::uint8_t *indata)
{
-// GNASH_REPORT_FUNCTION;
+ UNUSED(indata);
_type = Element::LONG_STRING_AMF0;
// check_buffer(size);
// _buffer->copy(indata, size);
@@ -1340,7 +1340,7 @@
Element &
Element::makeRecordSet(boost::uint8_t *data)
{
-// GNASH_REPORT_FUNCTION;
+ UNUSED(data);
_type = Element::RECORD_SET_AMF0;
return *this;
}
@@ -1374,7 +1374,7 @@
Element::makeDate(double date)
{
// GNASH_REPORT_FUNCTION;
- boost::uint8_t *ptr = reinterpret_cast<boost::uint8_t *>(&date);
+ //boost::uint8_t *ptr = reinterpret_cast<boost::uint8_t *>(&date);
_type = Element::DATE_AMF0;
try {
check_buffer(AMF0_NUMBER_SIZE);
=== modified file 'libnet/http.cpp'
--- a/libnet/http.cpp 2009-02-17 01:02:00 +0000
+++ b/libnet/http.cpp 2009-02-19 09:17:14 +0000
@@ -141,7 +141,7 @@
HTTP::processClientRequest(int fd)
{
// GNASH_REPORT_FUNCTION;
- bool result;
+ bool result = false;
boost::shared_ptr<amf::Buffer> buf(_que.peek());
if (buf) {
=== modified file 'libnet/network.cpp'
--- a/libnet/network.cpp 2008-12-30 21:06:48 +0000
+++ b/libnet/network.cpp 2009-02-19 09:17:14 +0000
@@ -1017,7 +1017,7 @@
#ifdef HAVE_PSELECT
struct timespec tval;
- sigset_t pending, blockset;
+ sigset_t pending, blockset; //, emptyset;
sigemptyset(&blockset);
// sigaddset(&blockset, SIGINT); /* Block SIGINT */
sigaddset(&blockset, SIGPIPE);
@@ -1211,7 +1211,7 @@
#ifdef HAVE_PPOLL
struct timespec tval;
- sigset_t pending, emptyset, blockset;
+ sigset_t pending, blockset;
sigemptyset(&blockset); /* Block SIGINT */
// sigaddset(&blockset, SIGINT);
// sigaddset(&blockset, SIGPIPE);
=== modified file 'libnet/rtmp.cpp'
--- a/libnet/rtmp.cpp 2009-02-14 22:42:54 +0000
+++ b/libnet/rtmp.cpp 2009-02-19 09:17:14 +0000
@@ -44,16 +44,34 @@
#include "utility.h"
#include "buffer.h"
-using namespace gnash;
-using namespace std;
+using std::cerr;
+using std::endl;
using namespace amf;
namespace gnash
{
+namespace {
+
+ /// Function object for matching C strings alphabetically.
+ class MatchFirst
+ {
+ public:
+ MatchFirst(const char* match) : _match(match) {}
+
+ bool operator()(const RTMP::AMFProperties::value_type& a) {
+ return std::strcmp(a.first, _match) == 0;
+ }
+ private:
+ const char* _match;
+ };
+
+}
+
+
CQue incoming;
-extern map<int, Handler *> handlers;
+extern std::map<int, Handler *> handlers;
const char *content_str[] = {
"None",
@@ -153,7 +171,7 @@
int headersize = -1;
- cerr << "Header size value: " << (void *)header << endl;
+ cerr << "Header size value: " << (void *)header << std::endl;
switch (header & RTMP_HEADSIZE_MASK) {
case HEADER_12:
@@ -192,7 +210,7 @@
{
// Name is only used for debugging
boost::format fmt("channel #%s");
- string name = (fmt % i).str();
+ std::string name = (fmt % i).str();
_queues[i].setName(name.c_str());
// each channel can have a different chunksize
@@ -225,20 +243,18 @@
_properties[name] = el;
}
+
amf::Element &
RTMP::getProperty(const std::string &name)
{
-// GNASH_REPORT_FUNCTION;
-// return _properties[name.c_str()];
- map<const char *, amf::Element>::iterator it;
- for (it = _properties.begin(); it != _properties.end(); it++) {
- const char *title = it->first;
- amf::Element &el = it->second;
- if (name == title) {
-// log_debug("found variable in RTMP packet: %s", name);
- return el;
- }
- }
+ // Find without inserting.
+ AMFProperties::iterator it = std::find_if(_properties.begin(),
+ _properties.end(), MatchFirst(name.c_str()));
+
+ // If this fails and we return, it will corrupt memory, so either
+ // the assertion never fails or we'll have to return a pointer.
+ assert(it != _properties.end());
+ return it->second;
}
boost::shared_ptr<RTMP::rtmp_head_t>
@@ -512,7 +528,7 @@
RTMP::dump()
{
cerr << "RTMP packet contains " << _properties.size() << " variables." <<
endl;
- map<const char *, amf::Element>::iterator it;
+ AMFProperties::iterator it;
for (it = _properties.begin(); it != _properties.end(); it++) {
// const char *name = it->first;
amf::Element el = it->second;
@@ -877,7 +893,7 @@
// After the first packet, only send the single byte
// continuation packet.
if (nbytes > 0) {
- int ret = writeNet(fd, *cont_head);
+ ret = writeNet(fd, *cont_head);
}
// write the data to the client
ret = writeNet(fd, data + nbytes, partial);
@@ -1063,7 +1079,7 @@
GNASH_REPORT_FUNCTION;
int ret = 0;
- bool nopacket = true;
+ //bool nopacket = true;
// Read really big packets, they get split into the smaller ones when
'split'
boost::shared_ptr<amf::Buffer> buf(new Buffer(7096));
@@ -1085,7 +1101,7 @@
}
// ret is "no position" when the socket is closed from the other end of
the connection,
// so we're done.
- if ((ret == static_cast<int>(string::npos)) || (ret == -1)) {
+ if ((ret == static_cast<int>(std::string::npos)) || (ret == -1)) {
log_debug("socket for fd #%d was closed...", fd);
buf.reset();
break;
@@ -1127,7 +1143,7 @@
boost::uint8_t *ptr = 0;
boost::shared_ptr<rtmp_head_t> rthead(new rtmp_head_t);
size_t pktsize = 0;
- size_t nbytes = 0;
+ //size_t nbytes = 0;
ptr = data;
boost::shared_ptr<amf::Buffer> chunk;
=== modified file 'libnet/rtmp.h'
--- a/libnet/rtmp.h 2009-02-14 22:42:54 +0000
+++ b/libnet/rtmp.h 2009-02-19 09:17:14 +0000
@@ -15,8 +15,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#ifndef _RTMP_H_
-#define _RTMP_H_
+#ifndef GNASH_LIBNET_RTMP_H
+#define GNASH_LIBNET_RTMP_H
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
@@ -78,6 +78,7 @@
class DSOEXPORT RTMP : public Network
{
public:
+ typedef std::map<const char*, amf::Element> AMFProperties;
typedef std::deque<CQue *> queues_t;
typedef enum {
RAW=0x0,
@@ -302,7 +303,7 @@
CQue &operator[] (size_t x) { return _queues[x]; }
void dump();
protected:
- std::map<const char *, amf::Element> _properties;
+ AMFProperties _properties;
amf::Buffer *_handshake;
Handler *_handler;
rtmp_head_t _header;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10595: Merge compiler warning fixes from 0.8.5 branch.,
Benjamin Wolsey <=