diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-04-02 16:13:23 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-06-24 13:42:54 +0200 |
commit | 139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901 (patch) | |
tree | 8d06ede9e14516516a44c5ed710058003088eec2 /unix/xserver/hw/vnc | |
parent | 45198e5235f4b724277665b242cf855a0ff4518b (diff) | |
download | tigervnc-139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901.tar.gz tigervnc-139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901.zip |
Use nullptr in all C++ code
It's more readable than 0, and a bit safer than NULL, so let's try to
follow modern norms.
Diffstat (limited to 'unix/xserver/hw/vnc')
-rw-r--r-- | unix/xserver/hw/vnc/RFBGlue.cc | 36 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 6 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 6 |
3 files changed, 24 insertions, 24 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc index 25431b65..2cbee35c 100644 --- a/unix/xserver/hw/vnc/RFBGlue.cc +++ b/unix/xserver/hw/vnc/RFBGlue.cc @@ -51,7 +51,7 @@ void vncLogError(const char *name, const char *format, ...) LogWriter *vlog; va_list ap; vlog = LogWriter::getLogWriter(name); - if (vlog == NULL) + if (vlog == nullptr) return; va_start(ap, format); vlog->verror(format, ap); @@ -63,7 +63,7 @@ void vncLogStatus(const char *name, const char *format, ...) LogWriter *vlog; va_list ap; vlog = LogWriter::getLogWriter(name); - if (vlog == NULL) + if (vlog == nullptr) return; va_start(ap, format); vlog->vstatus(format, ap); @@ -75,7 +75,7 @@ void vncLogInfo(const char *name, const char *format, ...) LogWriter *vlog; va_list ap; vlog = LogWriter::getLogWriter(name); - if (vlog == NULL) + if (vlog == nullptr) return; va_start(ap, format); vlog->vinfo(format, ap); @@ -87,7 +87,7 @@ void vncLogDebug(const char *name, const char *format, ...) LogWriter *vlog; va_list ap; vlog = LogWriter::getLogWriter(name); - if (vlog == NULL) + if (vlog == nullptr) return; va_start(ap, format); vlog->vdebug(format, ap); @@ -96,12 +96,12 @@ void vncLogDebug(const char *name, const char *format, ...) int vncSetParam(const char *name, const char *value) { - if (value != NULL) + if (value != nullptr) return rfb::Configuration::setParam(name, value); else { VoidParameter *param; param = rfb::Configuration::getParam(name); - if (param == NULL) + if (param == nullptr) return false; return param->setParam(); } @@ -118,11 +118,11 @@ char* vncGetParam(const char *name) // Hack to avoid exposing password! if (strcasecmp(name, "Password") == 0) - return NULL; + return nullptr; param = rfb::Configuration::getParam(name); - if (param == NULL) - return NULL; + if (param == nullptr) + return nullptr; return strdup(param->getValueStr().c_str()); } @@ -132,8 +132,8 @@ const char* vncGetParamDesc(const char *name) rfb::VoidParameter *param; param = rfb::Configuration::getParam(name); - if (param == NULL) - return NULL; + if (param == nullptr) + return nullptr; return param->getDescription(); } @@ -144,11 +144,11 @@ int vncIsParamBool(const char *name) BoolParameter *bparam; param = rfb::Configuration::getParam(name); - if (param == NULL) + if (param == nullptr) return false; bparam = dynamic_cast<BoolParameter*>(param); - if (bparam == NULL) + if (bparam == nullptr) return false; return true; @@ -179,8 +179,8 @@ char *vncGetParamList(void) } data = (char*)malloc(len + 1); - if (data == NULL) - return NULL; + if (data == nullptr) + return nullptr; ptr = data; for (ParameterIterator i; i.param; i.next()) { @@ -227,7 +227,7 @@ char* vncConvertLF(const char* src, size_t bytes) try { return strdup(convertLF(src, bytes).c_str()); } catch (...) { - return NULL; + return nullptr; } } @@ -236,7 +236,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes) try { return strdup(latin1ToUTF8(src, bytes).c_str()); } catch (...) { - return NULL; + return nullptr; } } @@ -245,7 +245,7 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes) try { return strdup(utf8ToLatin1(src, bytes).c_str()); } catch (...) { - return NULL; + return nullptr; } } diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index d4ee16b8..a38087b4 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -80,7 +80,7 @@ XserverDesktop::XserverDesktop(int screenIndex_, void* fbptr, int stride_) : screenIndex(screenIndex_), server(0), listeners(listeners_), - shadowFramebuffer(NULL), + shadowFramebuffer(nullptr), queryConnectId(0), queryConnectTimer(this) { format = pf; @@ -123,7 +123,7 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_) if (shadowFramebuffer) { delete [] shadowFramebuffer; - shadowFramebuffer = NULL; + shadowFramebuffer = nullptr; } if (!fbptr) { @@ -521,7 +521,7 @@ void XserverDesktop::handleClipboardData(const char* data_) void XserverDesktop::grabRegion(const rfb::Region& region) { - if (shadowFramebuffer == NULL) + if (shadowFramebuffer == nullptr) return; std::vector<rfb::Rect> rects; diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 4003e768..073b07e2 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -114,10 +114,10 @@ static const char* defaultDesktopName() return ""; struct passwd* pwent = getpwuid(getuid()); - if (pwent == NULL) + if (pwent == nullptr) return ""; - size_t len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data()); + size_t len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data()); if (len < 0) return ""; @@ -286,7 +286,7 @@ void vncExtensionClose(void) try { for (int scr = 0; scr < vncGetScreenCount(); scr++) { delete desktop[scr]; - desktop[scr] = NULL; + desktop[scr] = nullptr; } } catch (rdr::Exception& e) { vncFatalError("vncExtInit: %s\n",e.str()); |