Ticket #5287: libs_libmythupnp-init-vars.patch

File libs_libmythupnp-init-vars.patch, 5.0 KB (added by Erik Hovland <erik@…>, 12 years ago)

deals with uninitialized member variables and variables

  • libs/libmythupnp/eventing.h

    Initialized any variables that need it.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythupnp/eventing.h         |   40 ++++++++++++-----------------------
     libs/libmythupnp/upnp.cpp           |    3 ++-
     libs/libmythupnp/upnp.h             |    2 +-
     libs/libmythupnp/upnpcdsobjects.cpp |   14 ++++--------
     libs/libmythupnp/upnpcdsobjects.h   |    2 +-
     5 files changed, 23 insertions(+), 38 deletions(-)
    
    diff --git a/libs/libmythupnp/eventing.h b/libs/libmythupnp/eventing.h
    index f795df6..44d21dd 100644
    a b  
    3131class SubscriberInfo
    3232{
    3333    public:
    34 
    35         TaskTime            ttExpires;
    36         TaskTime            ttLastNotified;
    37 
    38         QString             sUUID;
    39         Q3Url                qURL;
    40         unsigned short      nKey;
    41         unsigned long       nDuration;       // Seconds
    42 
    43     public:
    44 
    45         // ------------------------------------------------------------------
    46 
    4734        SubscriberInfo()
     35            : nKey( 0 ), nDuration( 0 )
    4836        {
    49             nKey           = 0;
    50             nDuration      = 0;
    51             ttLastNotified.tv_sec = 0;
     37            bzero( &ttExpires, sizeof( ttExpires ) );
     38            bzero( &ttLastNotified, sizeof( ttLastNotified ) );
    5239            sUUID          = QUuid::createUuid().toString();
    5340            sUUID          = sUUID.mid( 1, sUUID.length() - 2);
    54 
    55 
    5641        }
    5742
    58         // ------------------------------------------------------------------
    59 
    6043        SubscriberInfo( const QString &url, unsigned long duration )
     44            : nKey( 0 ), nDuration( duration )
    6145        {
    62             nKey           = 0;
     46            bzero( &ttExpires, sizeof( ttExpires ) );
     47            bzero( &ttLastNotified, sizeof( ttLastNotified ) );
    6348            sUUID          = QUuid::createUuid().toString();
    6449            sUUID          = sUUID.mid( 1, sUUID.length() - 2);
    6550            qURL           = url;
    66             nDuration      = duration;
    67             ttLastNotified.tv_sec = 0;
    6851
    6952            SetExpireTime( nDuration );
    7053        }
    7154
    72         // ------------------------------------------------------------------
    73 
    7455        unsigned long IncrementKey()
    7556        {
    7657            // When key wraps around to zero again... must make it a 1. (upnp spec)
    77 
    7858            if ((++nKey) == 0)
    7959                nKey = 1;
    8060
    8161            return nKey;
    8262        }
    8363
     64        TaskTime            ttExpires;
     65        TaskTime            ttLastNotified;
     66
     67        QString             sUUID;
     68        Q3Url                qURL;
     69        unsigned short      nKey;
     70        unsigned long       nDuration;       // Seconds
     71
    8472    protected:
    8573
    8674        void SetExpireTime( unsigned long nSecs )
  • libs/libmythupnp/upnp.cpp

    diff --git a/libs/libmythupnp/upnp.cpp b/libs/libmythupnp/upnp.cpp
    index e0e4509..ff3137d 100644
    a b Configuration *UPnp::g_pConfig = NULL; 
    3838//////////////////////////////////////////////////////////////////////////////
    3939
    4040UPnp::UPnp()
     41    : m_pHttpServer(NULL), m_nServicePort(NULL)
    4142{
    4243    VERBOSE( VB_UPNP, "UPnp - Constructor" );
    4344}
    void UPnp::Start() 
    157158//
    158159//////////////////////////////////////////////////////////////////////////////
    159160
    160 void UPnp::CleanUp( void )
     161void UPnp::CleanUp()
    161162{
    162163    if (g_pSSDP)
    163164    {
  • libs/libmythupnp/upnp.h

    diff --git a/libs/libmythupnp/upnp.h b/libs/libmythupnp/upnp.h
    index ec5d6aa..c81d040 100644
    a b class UPnp 
    119119
    120120        virtual void Start();
    121121
    122         void CleanUp      ( void );
     122        void CleanUp      ();
    123123
    124124        UPnpDevice *RootDevice() { return &(g_UPnpDeviceDesc.m_rootDevice); }
    125125
  • libs/libmythupnp/upnpcdsobjects.cpp

    diff --git a/libs/libmythupnp/upnpcdsobjects.cpp b/libs/libmythupnp/upnpcdsobjects.cpp
    index 47b21f5..3dc576e 100644
    a b inline QString GetBool( bool bVal ) { return( (bVal) ? "1" : "0" ); } 
    2626CDSObject::CDSObject( const QString sId,
    2727                      const QString sTitle,
    2828                      const QString sParentId )
     29    : m_nUpdateId(1), m_eType(OT_Container)
     30    , m_sId(sId), m_sParentId(sParentId)
     31    , m_sTitle(sTitle), m_bRestricted(true)
     32    , m_bSearchable(false), m_sWriteStatus("PROTECTED")
     33    , m_nChildCount(-1)
    2934{
    30     m_sId          = sId;
    31     m_sParentId    = sParentId;
    32     m_eType        = OT_Container;
    33     m_sTitle       = sTitle;
    34     m_bRestricted  = true;
    35     m_sWriteStatus = "PROTECTED";
    36     m_nChildCount  = 0;
    37     m_nUpdateId    = 1;
    38 
    3935    HTTPRequest::Encode( m_sId       );
    4036    HTTPRequest::Encode( m_sParentId );
    4137    HTTPRequest::Encode( m_sTitle    );
  • libs/libmythupnp/upnpcdsobjects.h

    diff --git a/libs/libmythupnp/upnpcdsobjects.h b/libs/libmythupnp/upnpcdsobjects.h
    index 914144b..8b692f9 100644
    a b typedef Q3PtrList < ContainerClass > Classes; 
    125125class CDSObject
    126126{
    127127    public:
    128         short            m_nUpdateId;
     128        short           m_nUpdateId;
    129129
    130130        ObjectTypes     m_eType;
    131131