Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 938356b

Browse files
committedJun 20, 2018
Replace defined NULL with C++ nullptr
Kind of pedantic, but raised as an issue...
1 parent b120d14 commit 938356b

File tree

12 files changed

+624
-628
lines changed

12 files changed

+624
-628
lines changed
 

‎ethminer/DBusInt.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DBusInt
3333
cerr << "Message is null!" << endl;
3434
}
3535
dbus_message_append_args(msg, DBUS_TYPE_STRING, &hash, DBUS_TYPE_INVALID);
36-
if (!dbus_connection_send(conn, msg, NULL)) cerr << "Error sending message!" << endl;
36+
if (!dbus_connection_send(conn, msg, nulltr)) cerr << "Error sending message!" << endl;
3737
dbus_message_unref(msg);
3838
}
3939

‎libapicore/httpServer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ void httpServer::run_thread()
104104
struct mg_mgr mgr;
105105
struct mg_connection* c;
106106

107-
mg_mgr_init(&mgr, NULL);
107+
mg_mgr_init(&mgr, nullptr);
108108
cnote << "Starting web server on port " << m_port;
109109
c = mg_bind(&mgr, m_port.c_str(), ev_handler);
110-
if (c == NULL) {
110+
if (c == nullptr) {
111111
cwarn << "Failed to create web listener";
112112
return;
113113
}

‎libethash-cl/CL/cl2.hpp

+564-564
Large diffs are not rendered by default.

‎libethash-cl/CLMiner.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ bool CLMiner::init(int epoch)
589589
if (platformId == OPENCL_PLATFORM_NVIDIA) {
590590
cl_uint computeCapabilityMajor;
591591
cl_uint computeCapabilityMinor;
592-
clGetDeviceInfo(device(), CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof(cl_uint), &computeCapabilityMajor, NULL);
593-
clGetDeviceInfo(device(), CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof(cl_uint), &computeCapabilityMinor, NULL);
592+
clGetDeviceInfo(device(), CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof(cl_uint), &computeCapabilityMajor, nullptr);
593+
clGetDeviceInfo(device(), CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof(cl_uint), &computeCapabilityMinor, nullptr);
594594

595595
computeCapability = computeCapabilityMajor * 10 + computeCapabilityMinor;
596596
int maxregs = computeCapability >= 35 ? 72 : 63;
@@ -608,7 +608,7 @@ bool CLMiner::init(int epoch)
608608

609609
if (s_adjustWorkSize) {
610610
unsigned int computeUnits;
611-
clGetDeviceInfo(device(), CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(computeUnits), &computeUnits, NULL);
611+
clGetDeviceInfo(device(), CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(computeUnits), &computeUnits, nullptr);
612612
// Apparently some 36 CU devices return a bogus 14!!!
613613
computeUnits = computeUnits == 14 ? 36 : computeUnits;
614614
if ((platformId == OPENCL_PLATFORM_AMD) && (computeUnits != 36)) {

‎libethash-cuda/CUDAMiner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool CUDAMiner::init(int epoch)
6464
{
6565
// all devices have loaded DAG, we can free now
6666
delete[] s_dagInHostMemory;
67-
s_dagInHostMemory = NULL;
67+
s_dagInHostMemory = nullptr;
6868
cnote << "Freeing DAG from host";
6969
}
7070
}

‎libethcore/Farm.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,10 @@ class Farm: public FarmFace
533533

534534
unsigned m_tstart = 0, m_tstop = 0;
535535

536-
wrap_nvml_handle *nvmlh = NULL;
537-
wrap_adl_handle *adlh = NULL;
536+
wrap_nvml_handle *nvmlh = nullptr;
537+
wrap_adl_handle *adlh = nullptr;
538538
#if defined(__linux)
539-
wrap_amdsysfs_handle *sysfsh = NULL;
539+
wrap_amdsysfs_handle *sysfsh = nullptr;
540540
#endif
541541
};
542542

‎libethcore/Miner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ unsigned dev::eth::Miner::s_dagLoadIndex = 0;
1010

1111
unsigned dev::eth::Miner::s_dagCreateDevice = 0;
1212

13-
uint8_t* dev::eth::Miner::s_dagInHostMemory = NULL;
13+
uint8_t* dev::eth::Miner::s_dagInHostMemory = nullptr;
1414

1515
bool dev::eth::Miner::s_exit = false;
1616

‎libhwmon/wrapadl.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void* ADL_API_CALL ADL_Main_Memory_Alloc(int iSize)
2222

2323
wrap_adl_handle * wrap_adl_create()
2424
{
25-
wrap_adl_handle *adlh = NULL;
25+
wrap_adl_handle *adlh = nullptr;
2626

2727
#if defined(_WIN32)
2828
/* Windows */
@@ -36,7 +36,7 @@ wrap_adl_handle * wrap_adl_create()
3636
#else
3737
#define libatiadlxx ""
3838
#warning "Unrecognized platform: need ADL DLL path for this platform..."
39-
return NULL;
39+
return nullptr;
4040
#endif
4141

4242
#ifdef _WIN32
@@ -47,8 +47,8 @@ return NULL;
4747
#endif
4848

4949
void *adl_dll = wrap_dlopen(tmp);
50-
if (adl_dll == NULL)
51-
return NULL;
50+
if (adl_dll == nullptr)
51+
return nullptr;
5252

5353
adlh = (wrap_adl_handle *)calloc(1, sizeof(wrap_adl_handle));
5454

@@ -80,31 +80,31 @@ return NULL;
8080
wrap_dlsym(adlh->adl_dll, "ADL2_Main_Control_Refresh");
8181

8282

83-
if (adlh->adlMainControlCreate == NULL ||
84-
adlh->adlMainControlDestroy == NULL ||
85-
adlh->adlMainControlRefresh == NULL ||
86-
adlh->adlAdapterNumberOfAdapters == NULL ||
87-
adlh->adlAdapterAdapterInfoGet == NULL ||
88-
adlh->adlAdapterAdapterIdGet == NULL ||
89-
adlh->adlOverdrive5TemperatureGet == NULL ||
90-
adlh->adlOverdrive5FanSpeedGet == NULL ||
91-
adlh->adl2MainControlCreate == NULL ||
92-
adlh->adl2MainControlRefresh == NULL ||
93-
adlh->adl2MainControlDestroy == NULL ||
94-
adlh->adl2Overdrive6CurrentPowerGet == NULL
83+
if (adlh->adlMainControlCreate == nullptr ||
84+
adlh->adlMainControlDestroy == nullptr ||
85+
adlh->adlMainControlRefresh == nullptr ||
86+
adlh->adlAdapterNumberOfAdapters == nullptr ||
87+
adlh->adlAdapterAdapterInfoGet == nullptr ||
88+
adlh->adlAdapterAdapterIdGet == nullptr ||
89+
adlh->adlOverdrive5TemperatureGet == nullptr ||
90+
adlh->adlOverdrive5FanSpeedGet == nullptr ||
91+
adlh->adl2MainControlCreate == nullptr ||
92+
adlh->adl2MainControlRefresh == nullptr ||
93+
adlh->adl2MainControlDestroy == nullptr ||
94+
adlh->adl2Overdrive6CurrentPowerGet == nullptr
9595
) {
9696
#if 0
9797
printf("Failed to obtain all required ADL function pointers\n");
9898
#endif
9999
wrap_dlclose(adlh->adl_dll);
100100
free(adlh);
101-
return NULL;
101+
return nullptr;
102102
}
103103

104104
adlh->adlMainControlCreate(ADL_Main_Memory_Alloc, 1);
105105
adlh->adlMainControlRefresh();
106106

107-
adlh->context = NULL;
107+
adlh->context = nullptr;
108108

109109
adlh->adl2MainControlCreate(ADL_Main_Memory_Alloc, 1, &(adlh->context));
110110
adlh->adl2MainControlRefresh(adlh->context);
@@ -174,7 +174,7 @@ return NULL;
174174
cl::Device cldev = platdevs[j];
175175
cl_device_topology_amd topology;
176176
int status = clGetDeviceInfo (cldev(), CL_DEVICE_TOPOLOGY_AMD,
177-
sizeof(cl_device_topology_amd), &topology, NULL);
177+
sizeof(cl_device_topology_amd), &topology, nullptr);
178178
if(status == CL_SUCCESS) {
179179
if (topology.raw.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD) {
180180
if(adlh->devs[adlh->phys_logi_device_id[i]].iBusNumber == (int)topology.pcie.bus

‎libhwmon/wrapamdsysfs.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ static bool getFileContentValue(const char* filename, unsigned int& value)
4242

4343
wrap_amdsysfs_handle * wrap_amdsysfs_create()
4444
{
45-
wrap_amdsysfs_handle *sysfsh = NULL;
45+
wrap_amdsysfs_handle *sysfsh = nullptr;
4646

4747
#if defined(__linux)
4848
sysfsh = (wrap_amdsysfs_handle *)calloc(1, sizeof(wrap_amdsysfs_handle));
4949

5050
DIR* dirp = opendir("/sys/class/drm");
5151
if (dirp == nullptr)
52-
return NULL;
52+
return nullptr;
5353

5454
unsigned int gpucount = 0;
5555
struct dirent* dire;
@@ -68,7 +68,7 @@ wrap_amdsysfs_handle * wrap_amdsysfs_create()
6868
if (errno != 0)
6969
{
7070
closedir(dirp);
71-
return NULL;
71+
return nullptr;
7272
}
7373
closedir(dirp);
7474

@@ -105,7 +105,7 @@ wrap_amdsysfs_handle * wrap_amdsysfs_create()
105105
// Should not happen
106106
if (sysfsIdx < 0) {
107107
free(sysfsh);
108-
return NULL;
108+
return nullptr;
109109
}
110110

111111
// search hwmon
@@ -114,7 +114,7 @@ wrap_amdsysfs_handle * wrap_amdsysfs_create()
114114
DIR* dirp = opendir(dbuf);
115115
if (dirp == nullptr) {
116116
free(sysfsh);
117-
return NULL;
117+
return nullptr;
118118
}
119119
errno = 0;
120120
struct dirent* dire;
@@ -135,12 +135,12 @@ wrap_amdsysfs_handle * wrap_amdsysfs_create()
135135
{
136136
closedir(dirp);
137137
free(sysfsh);
138-
return NULL;
138+
return nullptr;
139139
}
140140
closedir(dirp);
141141
if (hwmonIndex == UINT_MAX) {
142142
free(sysfsh);
143-
return NULL;
143+
return nullptr;
144144
}
145145

146146
sysfsh->sysfs_hwmon_id[i] = hwmonIndex;
@@ -173,7 +173,7 @@ wrap_amdsysfs_handle * wrap_amdsysfs_create()
173173
cl::Device cldev = platdevs[j];
174174
cl_device_topology_amd topology;
175175
int status = clGetDeviceInfo(cldev(), CL_DEVICE_TOPOLOGY_AMD,
176-
sizeof(cl_device_topology_amd), &topology, NULL);
176+
sizeof(cl_device_topology_amd), &topology, nullptr);
177177
if (status == CL_SUCCESS) {
178178
if (topology.raw.type == CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD) {
179179

‎libhwmon/wrapnvml.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C" {
3030
#endif
3131

3232
wrap_nvml_handle * wrap_nvml_create() {
33-
wrap_nvml_handle *nvmlh = NULL;
33+
wrap_nvml_handle *nvmlh = nullptr;
3434

3535
/*
3636
* We use hard-coded library installation locations for the time being...
@@ -50,7 +50,7 @@ wrap_nvml_handle * wrap_nvml_create() {
5050
#else
5151
#define libnvidia_ml ""
5252
#warning "Unrecognized platform: need NVML DLL path for this platform..."
53-
return NULL;
53+
return nullptr;
5454
#endif
5555

5656
#ifdef _WIN32
@@ -61,8 +61,8 @@ return NULL;
6161
#endif
6262

6363
void *nvml_dll = wrap_dlopen(tmp);
64-
if (nvml_dll == NULL)
65-
return NULL;
64+
if (nvml_dll == nullptr)
65+
return nullptr;
6666

6767
nvmlh = (wrap_nvml_handle *) calloc(1, sizeof(wrap_nvml_handle));
6868

@@ -87,22 +87,22 @@ return NULL;
8787
nvmlh->nvmlShutdown = (wrap_nvmlReturn_t (*)())
8888
wrap_dlsym(nvmlh->nvml_dll, "nvmlShutdown");
8989

90-
if (nvmlh->nvmlInit == NULL ||
91-
nvmlh->nvmlShutdown == NULL ||
92-
nvmlh->nvmlDeviceGetCount == NULL ||
93-
nvmlh->nvmlDeviceGetHandleByIndex == NULL ||
94-
nvmlh->nvmlDeviceGetPciInfo == NULL ||
95-
nvmlh->nvmlDeviceGetName == NULL ||
96-
nvmlh->nvmlDeviceGetTemperature == NULL ||
97-
nvmlh->nvmlDeviceGetFanSpeed == NULL ||
98-
nvmlh->nvmlDeviceGetPowerUsage == NULL
90+
if (nvmlh->nvmlInit == nullptr ||
91+
nvmlh->nvmlShutdown == nullptr ||
92+
nvmlh->nvmlDeviceGetCount == nullptr ||
93+
nvmlh->nvmlDeviceGetHandleByIndex == nullptr ||
94+
nvmlh->nvmlDeviceGetPciInfo == nullptr ||
95+
nvmlh->nvmlDeviceGetName == nullptr ||
96+
nvmlh->nvmlDeviceGetTemperature == nullptr ||
97+
nvmlh->nvmlDeviceGetFanSpeed == nullptr ||
98+
nvmlh->nvmlDeviceGetPowerUsage == nullptr
9999
) {
100100
#if 0
101101
printf("Failed to obtain all required NVML function pointers\n");
102102
#endif
103103
wrap_dlclose(nvmlh->nvml_dll);
104104
free(nvmlh);
105-
return NULL;
105+
return nullptr;
106106
}
107107

108108
nvmlh->nvmlInit();
@@ -117,7 +117,7 @@ return NULL;
117117
#endif
118118
wrap_dlclose(nvmlh->nvml_dll);
119119
free(nvmlh);
120-
return NULL;
120+
return nullptr;
121121
}
122122
#endif
123123
nvmlh->devs = (wrap_nvmlDevice_t *) calloc(nvmlh->nvml_gpucount, sizeof(wrap_nvmlDevice_t));
@@ -197,9 +197,9 @@ return NULL;
197197
cl::Device cldev = platdevs[j];
198198
cl_int busId, slotId;
199199
int statusB = clGetDeviceInfo (cldev(), CL_DEVICE_PCI_BUS_ID_NV,
200-
sizeof(cl_int), &busId, NULL);
200+
sizeof(cl_int), &busId, nullptr);
201201
int statusS = clGetDeviceInfo (cldev(), CL_DEVICE_PCI_SLOT_ID_NV,
202-
sizeof(cl_int), &slotId, NULL);
202+
sizeof(cl_int), &slotId, nullptr);
203203
if(statusB == CL_SUCCESS && statusS == CL_SUCCESS) {
204204
if((unsigned)busId == nvmlh->nvml_pci_bus_id[i] && (unsigned)slotId == nvmlh->nvml_pci_device_id[i]) {
205205
#if 0

‎libpoolprotocols/PoolManager.h

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#include "PoolClient.h"
1111

12-
#if ETH_DBUS
13-
#include "DBusInt.h"
14-
#endif
15-
1612
using namespace std;
1713

1814
namespace dev

‎libpoolprotocols/stratum/EthStratumClient.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ void EthStratumClient::connect()
9797

9898
#ifdef _WIN32
9999
HCERTSTORE hStore = CertOpenSystemStore(0, "ROOT");
100-
if (hStore == NULL) {
100+
if (hStore == nullptr) {
101101
return;
102102
}
103103

104104
X509_STORE *store = X509_STORE_new();
105-
PCCERT_CONTEXT pContext = NULL;
106-
while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != NULL) {
107-
X509 *x509 = d2i_X509(NULL,
105+
PCCERT_CONTEXT pContext = nullptr;
106+
while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != nullptr) {
107+
X509 *x509 = d2i_X509(nullptr,
108108
(const unsigned char **)&pContext->pbCertEncoded,
109109
pContext->cbCertEncoded);
110-
if (x509 != NULL) {
110+
if (x509 != nullptr) {
111111
X509_STORE_add_cert(store, x509);
112112
X509_free(x509);
113113
}

0 commit comments

Comments
 (0)
This repository has been archived.