Ticket #5777: libs_libmythdb-krazy2-remove-null.patch

File libs_libmythdb-krazy2-remove-null.patch, 14.8 KB (added by Erik Hovland <erik@…>, 16 years ago)

Replaces NULL with 0 in C++ code in libmythdb

  • mythtv/libs/libmythdb/compat.h

    Remove NULL and replace it with 0.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     mythtv/libs/libmythdb/compat.h           |   10 +++++-----
     mythtv/libs/libmythdb/httpcomms.cpp      |   20 ++++++++++----------
     mythtv/libs/libmythdb/httpcomms.h        |   12 ++++++------
     mythtv/libs/libmythdb/lcddevice.cpp      |   14 +++++++-------
     mythtv/libs/libmythdb/mythdb.cpp         |    4 ++--
     mythtv/libs/libmythdb/mythdbcon.cpp      |    6 +++---
     mythtv/libs/libmythdb/mythobservable.cpp |    2 +-
     mythtv/libs/libmythdb/mythsocket.cpp     |   12 ++++++------
     mythtv/libs/libmythdb/mythsocket.h       |    2 +-
     mythtv/libs/libmythdb/mythverbose.h      |    2 +-
     mythtv/libs/libmythdb/oldsettings.cpp    |    2 +-
     11 files changed, 43 insertions(+), 43 deletions(-)
    
    diff --git a/mythtv/libs/libmythdb/compat.h b/mythtv/libs/libmythdb/compat.h
    index 3fb8f30..afd7bde 100644
    a b inline int usleep(unsigned int timeout) 
    100100    /*
    101101    // windows seems to have 1us-resolution timers,
    102102    // however this produces the same results as Sleep
    103     HANDLE hTimer = ::CreateWaitableTimer(NULL, TRUE, NULL);
     103    HANDLE hTimer = ::CreateWaitableTimer(0, TRUE, 0);
    104104    if (hTimer) {
    105105        LARGE_INTEGER li;
    106106        li.QuadPart = -((int)timeout * 10);
    107         if (SetWaitableTimer(hTimer, &li, 0, NULL, 0, FALSE)) {
     107        if (SetWaitableTimer(hTimer, &li, 0, 0, 0, FALSE)) {
    108108            DWORD res = WaitForSingleObject(hTimer, (timeout / 1000 + 1));
    109109            if (res == WAIT_TIMEOUT || res == WAIT_OBJECT_0)
    110110                return 0;
    inline int statfs(const char* path, struct statfs* buffer) 
    184184#define mkfifo(path, mode) \
    185185    (int)CreateNamedPipeA(path, PIPE_ACCESS_DUPLEX | WRITE_DAC, \
    186186                          PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, \
    187                           1024, 1024, 10000, NULL)
     187                          1024, 1024, 10000, 0)
    188188#endif // USING_MINGW
    189189
    190190#ifdef USING_MINGW
    inline const char *dlerror(void) 
    202202    if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
    203203                        FORMAT_MESSAGE_IGNORE_INSERTS |
    204204                        FORMAT_MESSAGE_MAX_WIDTH_MASK,
    205                         NULL, errCode,
     205                        0, errCode,
    206206                        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    207                         errStr, DLERR_MAX - 1, NULL))
     207                        errStr, DLERR_MAX - 1, 0))
    208208        snprintf(errStr, DLERR_MAX - 1,
    209209                 "dlopen()/dlsym() caused error %d", (int)errCode);
    210210
  • mythtv/libs/libmythdb/httpcomms.cpp

    diff --git a/mythtv/libs/libmythdb/httpcomms.cpp b/mythtv/libs/libmythdb/httpcomms.cpp
    index 33debf7..c4ce8c8 100644
    a b HttpComms::~HttpComms() 
    3838    if (m_timer)
    3939    {
    4040        delete m_timer;
    41         m_timer = NULL;
     41        m_timer = 0;
    4242    }
    4343
    4444    delete http;
    HttpComms::~HttpComms() 
    4646
    4747void HttpComms::init()
    4848{
    49  //   m_curRequest = NULL;
     49 //   m_curRequest = 0;
    5050    m_authNeeded = false;
    5151    http = new QHttp();
    5252    m_redirectedURL = "";
    5353    m_done = false;
    5454    m_statusCode = 0;
    5555    m_responseReason = "";
    56     m_timer = NULL;
     56    m_timer = 0;
    5757    m_timeout = false;
    5858   
    5959
    void HttpComms::request(QUrl &url, int timeoutms, bool allowGzip) 
    9090void HttpComms::request(QUrl               &url,
    9191                        QHttpRequestHeader &header,
    9292                        int                 timeoutms,
    93                         QIODevice          *pData /* = NULL*/ )
     93                        QIODevice          *pData /* = 0*/ )
    9494{
    9595    quint16 port = 80;
    9696
    QString HttpComms::getHttp(QString &url, 
    296296    int redirectCount = 0;
    297297    int timeoutCount = 0;
    298298    QString res = "";
    299     HttpComms *httpGrabber = NULL;
     299    HttpComms *httpGrabber = 0;
    300300    QString hostname = "";
    301301
    302302    while (1)
    QString HttpComms::getHttp(QString &url, 
    309309       
    310310        VERBOSE(VB_NETWORK, QString("getHttp: grabbing: %1").arg(qurl.toString()));
    311311
    312         if (httpGrabber != NULL)
     312        if (httpGrabber)
    313313            delete httpGrabber;
    314314       
    315315        httpGrabber = new HttpComms;
    bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS 
    388388    int timeoutCount = 0;
    389389    QByteArray data(0);
    390390    bool res = false;
    391     HttpComms *httpGrabber = NULL;
     391    HttpComms *httpGrabber = 0;
    392392    QString hostname = "";
    393393
    394394    while (1)
    bool HttpComms::getHttpFile(const QString& filename, QString& url, int timeoutMS 
    403403        VERBOSE(VB_NETWORK, QString("getHttp: grabbing: '%1'")
    404404                                    .arg(qurl.toString()));
    405405
    406         if (httpGrabber != NULL)
     406        if (httpGrabber)
    407407            delete httpGrabber;
    408408       
    409409        httpGrabber = new HttpComms;
    QString HttpComms::postHttp(QUrl &url , 
    515515    int redirectCount = 0;
    516516    int timeoutCount = 0;
    517517    QString res = "";
    518     HttpComms *httpGrabber = NULL;
     518    HttpComms *httpGrabber = 0;
    519519    QString hostname = "";
    520520
    521521    QHttpRequestHeader header( "POST", url.path() + url.encodedQuery());
    QString HttpComms::postHttp(QUrl &url , 
    554554       
    555555        VERBOSE(VB_NETWORK, QString("postHttp: grabbing: %1").arg(url.toString()));
    556556
    557         if (httpGrabber != NULL)
     557        if (httpGrabber)
    558558            delete httpGrabber;
    559559       
    560560        httpGrabber = new HttpComms;
  • mythtv/libs/libmythdb/httpcomms.h

    diff --git a/mythtv/libs/libmythdb/httpcomms.h b/mythtv/libs/libmythdb/httpcomms.h
    index bd11090..eaebcec 100644
    a b class MPUBLIC HttpComms : public QObject 
    6060    static QString getHttp(QString& url, int timeoutMS = 10000,
    6161                           int maxRetries = 3, int maxRedirects = 3,
    6262                           bool allowGzip = false,
    63                            Credentials* webCred = NULL,
     63                           Credentials* webCred = 0,
    6464                           bool isInQtEventThread = true);
    6565   
    6666    static bool getHttpFile(const QString& file, QString& url, int timeoutMS = 10000,
    6767                            int maxRetries = 3, int maxRedirects = 3,
    68                             bool allowGzip = false, Credentials* webCred = NULL);
     68                            bool allowGzip = false, Credentials* webCred = 0);
    6969   
    7070    static QString postHttp(QUrl               &url,
    71                             QHttpRequestHeader *pAddlHdr          = NULL,
    72                             QIODevice          *pData             = NULL,
     71                            QHttpRequestHeader *pAddlHdr          = 0,
     72                            QIODevice          *pData             = 0,
    7373                            int                 timeoutMS         = 10000,
    7474                            int                 maxRetries        = 3,
    7575                            int                 maxRedirects      = 3,
    7676                            bool                allowGzip         = false,
    77                             Credentials        *webCred           = NULL,
     77                            Credentials        *webCred           = 0,
    7878                            bool                isInQtEventThread = true );
    7979
    8080    void request(QUrl &url, int timeoutms = -1, bool allowGzip = false);
    81     void request(QUrl &url, QHttpRequestHeader &header, int timeoutms = -1, QIODevice *pData = NULL );
     81    void request(QUrl &url, QHttpRequestHeader &header, int timeoutms = -1, QIODevice *pData = 0 );
    8282   
    8383    void setCookie( const QString& cookie ) { m_cookie = cookie; }
    8484    const QString& getCookie() const { return m_cookie; }
  • mythtv/libs/libmythdb/lcddevice.cpp

    diff --git a/mythtv/libs/libmythdb/lcddevice.cpp b/mythtv/libs/libmythdb/lcddevice.cpp
    index a627152..721b0f8 100644
    a b static QString LOC = "lcddevice: "; 
    3333
    3434LCD::LCD()
    3535    : QObject(),
    36       socket(NULL),                 socketLock(QMutex::Recursive),
     36      socket(0),                    socketLock(QMutex::Recursive),
    3737      hostname("localhost"),        port(6545),
    3838      bConnected(false),
    3939
    LCD::LCD() 
    5252      lcd_showmusic_items(),
    5353      lcd_keystring(),
    5454
    55       GetLEDMask(NULL)
     55      GetLEDMask(0)
    5656{
    5757    send_buffer.clear(); last_command.clear();
    5858    lcd_showmusic_items.clear(); lcd_keystring.clear();
    LCD::LCD() 
    7373
    7474bool LCD::m_enabled = false;
    7575bool LCD::m_server_unavailable = false;
    76 class LCD *LCD::m_lcd = NULL;
     76class LCD *LCD::m_lcd = 0;
    7777
    7878class LCD * LCD::Get(void)
    7979{
    80     if (m_enabled && m_lcd == NULL && m_server_unavailable == false)
     80    if (m_enabled && !m_lcd && m_server_unavailable == false)
    8181        m_lcd = new LCD;
    8282    return m_lcd;
    8383}
    void LCD::SetupLCD (void) 
    9090    if (m_lcd)
    9191    {
    9292        delete m_lcd;
    93         m_lcd = NULL;
     93        m_lcd = 0;
    9494        m_server_unavailable = false;
    9595    }
    9696
    void LCD::SetupLCD (void) 
    104104        if (lcd->connectToHost(lcd_host, lcd_port) == false)
    105105        {
    106106            delete m_lcd;
    107             m_lcd = NULL;
     107            m_lcd = 0;
    108108            m_server_unavailable = false;
    109109        }
    110110    }
    void LCD::resetServer() 
    629629
    630630LCD::~LCD()
    631631{
    632     m_lcd = NULL;
     632    m_lcd = 0;
    633633
    634634    VERBOSE(VB_IMPORTANT|VB_EXTRA, LOC + "An LCD device is being snuffed out of "
    635635                    "existence (~LCD() was called)");
  • mythtv/libs/libmythdb/mythdb.cpp

    diff --git a/mythtv/libs/libmythdb/mythdb.cpp b/mythtv/libs/libmythdb/mythdb.cpp
    index d94dc79..6b6bbfd 100644
    a b  
    55#include "mythverbose.h"
    66#include "oldsettings.h"
    77
    8 static MythDB *mythdb = NULL;
     8static MythDB *mythdb = 0;
    99static QMutex dbLock;
    1010
    1111unsigned int db_messages = VB_IMPORTANT | VB_GENERAL;
    void MythDB::destroyMythDB(void) 
    2828    dbLock.lock();
    2929    if (mythdb)
    3030        delete mythdb;
    31     mythdb = NULL;
     31    mythdb = 0;
    3232    dbLock.unlock();
    3333}
    3434
  • mythtv/libs/libmythdb/mythdbcon.cpp

    diff --git a/mythtv/libs/libmythdb/mythdbcon.cpp b/mythtv/libs/libmythdb/mythdbcon.cpp
    index 615cbdc..801536d 100644
    a b MDBManager::MDBManager() 
    171171
    172172    m_sem = new QSemaphore(20);
    173173
    174     m_schedCon = NULL;
    175     m_DDCon = NULL;
     174    m_schedCon = 0;
     175    m_DDCon = 0;
    176176}
    177177
    178178MDBManager::~MDBManager()
    void MDBManager::CloseDatabases() 
    303303
    304304void InitMSqlQueryInfo(MSqlQueryInfo &qi)
    305305{
    306     qi.db = NULL;
     306    qi.db = 0;
    307307    qi.qsqldb = QSqlDatabase();
    308308    qi.returnConnection = true;
    309309}
  • mythtv/libs/libmythdb/mythobservable.cpp

    diff --git a/mythtv/libs/libmythdb/mythobservable.cpp b/mythtv/libs/libmythdb/mythobservable.cpp
    index f97bdfb..d52bbef 100644
    a b QObject* MythObservable::nextListener() 
    3535    if (m_listener_it != m_listeners.end())
    3636        return *m_listener_it;
    3737    else
    38         return NULL;
     38        return 0;
    3939}
    4040
    4141QList<QObject*> MythObservable::getListeners()
  • mythtv/libs/libmythdb/mythsocket.cpp

    diff --git a/mythtv/libs/libmythdb/mythsocket.cpp b/mythtv/libs/libmythdb/mythsocket.cpp
    index bae58c7..c75f2a3 100644
    a b bool MythSocket::DownRef(void) 
    9090
    9191    if (m_cb && ref == 0)
    9292    {
    93         m_cb = NULL;
     93        m_cb = 0;
    9494        m_readyread_thread.RemoveFromReadyRead(this);
    9595        // thread will downref & delete obj
    9696        return true;
    bool MythSocket::readStringList(QStringList &list, bool quickTimeout) 
    451451            tv.tv_sec = 0;
    452452            tv.tv_usec = 0;
    453453
    454             int rval = select(maxfd + 1, &rfds, NULL, NULL, &tv);
     454            int rval = select(maxfd + 1, &rfds, 0, 0, &tv);
    455455            if (rval)
    456456            {
    457457                if (bytesAvailable() == 0)
    void MythSocketThread::ShutdownReadyReadThread(void) 
    670670#ifdef USING_MINGW
    671671    if (readyreadevent) {
    672672        ::CloseHandle(readyreadevent);
    673         readyreadevent = NULL;
     673        readyreadevent = 0;
    674674    }
    675675#else
    676676    ::close(m_readyread_pipe[0]);
    void MythSocketThread::StartReadyReadThread(void) 
    686686        if (m_readyread_run == false)
    687687        {
    688688#ifdef USING_MINGW
    689             readyreadevent = ::CreateEvent(NULL, false, false, NULL);
     689            readyreadevent = ::CreateEvent(0, false, false, 0);
    690690            assert(readyreadevent);
    691691#else
    692692            int ret = pipe(m_readyread_pipe);
    void MythSocketThread::run(void) 
    824824            if (sock->state() == MythSocket::Connected
    825825                && !sock->m_notifyread && !isLocked(sock->m_lock))
    826826            {
    827                 HANDLE hEvent = ::CreateEvent(NULL, false, false, NULL);
     827                HANDLE hEvent = ::CreateEvent(0, false, false, 0);
    828828                if (!hEvent)
    829829                {
    830830                    VERBOSE(VB_IMPORTANT, "MythSocket: CreateEvent failed");
    void MythSocketThread::run(void) 
    918918            ++it;
    919919        }
    920920
    921         int rval = select(maxfd + 1, &rfds, NULL, NULL, NULL);
     921        int rval = select(maxfd + 1, &rfds, 0, 0, 0);
    922922        if (rval == -1)
    923923        {
    924924            VERBOSE(VB_SOCKET, "MythSocket: select returned error");
  • mythtv/libs/libmythdb/mythsocket.h

    diff --git a/mythtv/libs/libmythdb/mythsocket.h b/mythtv/libs/libmythdb/mythsocket.h
    index dcce51c..3ef8049 100644
    a b class MPUBLIC MythSocket : public MSocketDevice 
    6262    friend void ShutdownRRT(void);
    6363
    6464  public:
    65     MythSocket(int socket = -1, MythSocketCBs *cb = NULL);
     65    MythSocket(int socket = -1, MythSocketCBs *cb = 0);
    6666
    6767    enum State {
    6868        Connected,
  • mythtv/libs/libmythdb/mythverbose.h

    diff --git a/mythtv/libs/libmythdb/mythverbose.h b/mythtv/libs/libmythdb/mythverbose.h
    index 1fd303b..a2afe45 100644
    a b extern MPUBLIC unsigned int print_verbose_messages; 
    137137            {                                                \
    138138                struct tm      *tp;                          \
    139139                struct timeval  tv;                          \
    140                 gettimeofday(&tv, NULL);                     \
     140                gettimeofday(&tv, 0);                        \
    141141                tp = localtime(&tv.tv_sec);                  \
    142142                printf("%4d-%02d-%02d %2d:%02d:%02d.%03d ",  \
    143143                       1900+tp->tm_year, 1+tp->tm_mon,       \
  • mythtv/libs/libmythdb/oldsettings.cpp

    diff --git a/mythtv/libs/libmythdb/oldsettings.cpp b/mythtv/libs/libmythdb/oldsettings.cpp
    index 54292d7..a8810a8 100644
    a b Settings::Settings(QString strSettingsFile) 
    3636
    3737Settings::~Settings()
    3838{
    39     if (m_pSettings != NULL)
     39    if (m_pSettings)
    4040        delete m_pSettings;
    4141}
    4242