Skip to content

Commit 9c8e157

Browse files
committed
src: address lint-cpp and format-cpp review comments
Signed-off-by: Gaby Baghdadi <baghdadi@ca.ibm.com>
1 parent 52b79e1 commit 9c8e157

4 files changed

Lines changed: 80 additions & 67 deletions

File tree

‎src/node.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
851851
}
852852

853853
#ifdef __MVS__
854-
V8::SetFlagsFromString("--nohard_abort", sizeof("--nohard_abort")-1);
854+
V8::SetFlagsFromString("--nohard_abort", sizeof("--nohard_abort") - 1);
855855
#endif
856856

857857
// Anything that's still in v8_argv is not a V8 or a node option.

‎src/node_zos.cc‎

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
#include "node_zos.h"
23+
#include "env-inl.h"
2324
#include "node_internals.h"
2425
#include "node_watchdog.h"
25-
#include "env-inl.h"
2626

2727
#include <pthread.h>
2828
#include <signal.h>
@@ -47,7 +47,7 @@
4747
namespace {
4848

4949
uv_thread_t signalHandlerThread;
50-
char *galtStack = nullptr;
50+
char* galtStack = nullptr;
5151

5252
void __zosAtExit() {
5353
if (galtStack != nullptr) {
@@ -60,9 +60,9 @@ void __zosAtExit() {
6060
namespace node {
6161

6262
void zosDestroyThread() {
63-
uv_queue_work(NULL, NULL, NULL, NULL);
63+
uv_queue_work(nullptr, nullptr, nullptr, nullptr);
6464
SigintWatchdogHelper::GetInstance()->Stop();
65-
msgctl(uv_backend_fd(uv_default_loop()), IPC_RMID, NULL);
65+
msgctl(uv_backend_fd(uv_default_loop()), IPC_RMID, nullptr);
6666
// Tell zoslib that main process is terminating, for its diagnostics:
6767
__mainTerminating();
6868
}
@@ -75,16 +75,15 @@ static void SignalHandlerThread(void* data) {
7575
}
7676

7777
void zosCreateSignalHandler() {
78-
uv_thread_create(&signalHandlerThread, SignalHandlerThread, NULL);
78+
uv_thread_create(&signalHandlerThread, SignalHandlerThread, nullptr);
7979
// Block all signals on the main thread
8080
sigset_t set;
8181
sigfillset(&set);
82-
CHECK_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL));
82+
CHECK_EQ(0, pthread_sigmask(SIG_BLOCK, &set, nullptr));
8383
}
8484

8585
void zosCancelSignalHandler() {
86-
if (pthread_cancel(signalHandlerThread) == -1)
87-
abort();
86+
if (pthread_cancel(signalHandlerThread) == -1) abort();
8887
}
8988

9089
void zosSignalExit(int signo, siginfo_t* info, void* ucontext) {
@@ -93,9 +92,9 @@ void zosSignalExit(int signo, siginfo_t* info, void* ucontext) {
9392
struct sigaction new_action;
9493
new_action.sa_flags = SA_ONSTACK;
9594
new_action.sa_handler = SIG_DFL;
96-
sigaction(signo, &new_action, NULL);
95+
sigaction(signo, &new_action, nullptr);
9796
if (signo == SIGABRT)
98-
abort(); // from zoslib
97+
abort(); // from zoslib
9998
else
10099
raise(signo);
101100
}
@@ -104,10 +103,10 @@ void zosIgnorePipeChildSignals() {
104103
struct sigaction new_action;
105104
new_action.sa_handler = SIG_IGN;
106105
sigfillset(&new_action.sa_mask);
107-
sigaction(SIGPIPE, &new_action, NULL);
106+
sigaction(SIGPIPE, &new_action, nullptr);
108107
new_action.sa_handler = SIG_IGN;
109108
sigfillset(&new_action.sa_mask);
110-
sigaction(SIGCHLD, &new_action, NULL);
109+
sigaction(SIGCHLD, &new_action, nullptr);
111110
}
112111

113112
static void RegisterProduct() {
@@ -119,56 +118,60 @@ static void RegisterProduct() {
119118

120119
std::string val;
121120
if (credentials::SafeGetenv("NODE_SMF89_REGISTRATION_VERBOSE", &val))
122-
printf("Product registration data:\n"
123-
"Product Name: %s\n"
124-
"PID Name: %s\n"
125-
"Major Version: %s\n"
126-
"Product Owner: %s\n"
127-
"Feature Name: %s\n", product_name.c_str(), pid.c_str(),
128-
major_version.c_str(), product_owner.c_str(),
129-
feature_name.c_str());
130-
131-
unsigned long long rc =
132-
__registerProduct(major_version.c_str(), product_owner.c_str(),
133-
feature_name.c_str(), product_name.c_str(),
134-
pid.c_str());
121+
printf("Product registration data:\n"
122+
"Product Name: %s\n"
123+
"PID Name: %s\n"
124+
"Major Version: %s\n"
125+
"Product Owner: %s\n"
126+
"Feature Name: %s\n",
127+
product_name.c_str(),
128+
pid.c_str(),
129+
major_version.c_str(),
130+
product_owner.c_str(),
131+
feature_name.c_str());
132+
133+
uint64_t rc = __registerProduct(major_version.c_str(),
134+
product_owner.c_str(),
135+
feature_name.c_str(),
136+
product_name.c_str(),
137+
pid.c_str());
135138

136139
if (rc && !credentials::SafeGetenv("NODE_SMF89_SUPPRESS_WARNING", &val)) {
137-
fprintf(stderr, "WARNING: Could not register product with IFAUSAGE, "
138-
"rc = %llu\n", rc);
139-
if (const char* errorString = getIFAUsageErrorString(rc))
140-
fprintf(stderr, "%s\n", errorString);
141-
142-
fprintf(stderr,
143-
"WARNING: Product usage data may not be collected. For more "
144-
"details on the product registration data, set environment "
145-
"variable NODE_SMF89_REGISTRATION_VERBOSE=1. To suppress this "
146-
"warning message set the environment variable "
147-
"NODE_SMF89_SUPPRESS_WARNING=1.\n");
140+
fprintf(stderr,
141+
"WARNING: Could not register product with IFAUSAGE, "
142+
"rc = %llu\n",
143+
rc);
144+
if (const char* errorString = getIFAUsageErrorString(rc))
145+
fprintf(stderr, "%s\n", errorString);
146+
147+
fprintf(stderr,
148+
"WARNING: Product usage data may not be collected. For more "
149+
"details on the product registration data, set environment "
150+
"variable NODE_SMF89_REGISTRATION_VERBOSE=1. To suppress this "
151+
"warning message set the environment variable "
152+
"NODE_SMF89_SUPPRESS_WARNING=1.\n");
148153
}
149154
}
150155

151156
ExitCode zosStart() {
152157
// Initialize environment variables in zoslib:
153-
zoslib_config_t config {
154-
.RUNTIME_LIMIT_ENVAR = "__NODERUNTIMELIMIT",
155-
.CCSID_GUESS_BUF_SIZE_ENVAR = "__NODECCSIDGUESSBUFSIZE"
156-
};
158+
zoslib_config_t config{
159+
.RUNTIME_LIMIT_ENVAR = "__NODERUNTIMELIMIT",
160+
.CCSID_GUESS_BUF_SIZE_ENVAR = "__NODECCSIDGUESSBUFSIZE"};
157161
if (__update_envar_names(&config) != 0) {
158162
return ExitCode::kGenericUserError;
159163
}
160164

161165
// Create an alternate stack for signal processing
162-
const unsigned int STACK_SIZE = SIGSTKSZ + 1024*1024;
166+
const unsigned int STACK_SIZE = SIGSTKSZ + 1024 * 1024;
163167
galtStack = (char*)malloc(STACK_SIZE);
164168
if (galtStack == nullptr) {
165169
return ExitCode::kGenericUserError;
166170
}
167171
stack_t ss = {.ss_sp = galtStack, .ss_size = STACK_SIZE, .ss_flags = 0};
168172
sigaltstack(&ss, 0);
169173

170-
if (__doLogMemoryUsage())
171-
atexit(__zosAtExit);
174+
if (__doLogMemoryUsage()) atexit(__zosAtExit);
172175

173176
return ExitCode::kNoFailure;
174177
}

‎src/node_zos.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
#ifndef SRC_NODE_ZOS_
23-
#define SRC_NODE_ZOS_
22+
#ifndef SRC_NODE_ZOS_H_
23+
#define SRC_NODE_ZOS_H_
2424

2525
#include "node_exit_code.h"
2626

@@ -37,4 +37,4 @@ void zosIgnorePipeChildSignals();
3737
void zosDestroyThread();
3838

3939
} // namespace node
40-
#endif // SRC_NODE_ZOS_
40+
#endif // SRC_NODE_ZOS_H_

‎src/zos_setlibpath.cc‎

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace {
2121
class __setlibpath {
22-
public:
22+
public:
2323
__setlibpath() {
2424
char argv[PATH_MAX];
2525
char parent[PATH_MAX], *p;
@@ -37,51 +37,61 @@ class __setlibpath {
3737
* Resolve path to find true location of executable; don't use an
3838
* overridden realpath function from zoslib, since this header may
3939
* be used in an exe before libzoslib.so has been loaded.
40-
*/
41-
if (__realpath_a(argv, parent) == NULL) {
42-
fprintf(stderr, "Error: __realpath_a(%s) failed, errno=%d.\n" \
40+
*/
41+
if (__realpath_a(argv, parent) == nullptr) {
42+
fprintf(stderr,
43+
"Error: __realpath_a(%s) failed, errno=%d.\n"
4344
"Please report this error to IBM customer support.\n",
44-
argv, errno);
45+
argv,
46+
errno);
4547
return;
4648
}
4749

4850
/* Get parent directory. */
4951
p = dirname(parent);
50-
if (p == NULL) {
51-
fprintf(stderr, "Error: dirname(%s) failed, errno=%d (argv=%s).\n" \
52-
"Please report this error to IBM customer support.\n",
53-
parent, errno, argv);
52+
if (p == nullptr) {
53+
fprintf(stderr,
54+
"Error: dirname(%s) failed, errno=%d (argv=%s).\n"
55+
"Please report this error to IBM customer support.\n",
56+
parent,
57+
errno,
58+
argv);
5459
return;
5560
}
5661

5762
/* Get parent's parent directory. */
5863
char parent2[PATH_MAX + 1], *p2;
59-
strncpy(parent2, parent, sizeof(parent2)-1);
60-
parent2[sizeof(parent2)-1] = 0;
64+
strncpy(parent2, parent, sizeof(parent2) - 1);
65+
parent2[sizeof(parent2) - 1] = 0;
6166
p2 = dirname(parent2);
62-
if (p2 == NULL) {
63-
fprintf(stderr, "Error: dirname(%s) for parent failed, " \
64-
"errno=%d (argv=%s).\n" \
67+
if (p2 == nullptr) {
68+
fprintf(stderr,
69+
"Error: dirname(%s) for parent failed, "
70+
"errno=%d (argv=%s).\n"
6571
"Please report this error to IBM customer support.\n",
66-
parent2, errno, argv);
72+
parent2,
73+
errno,
74+
argv);
6775
return;
6876
}
6977

7078
/* Append new paths to libpath. */
7179
std::ostringstream libpath;
7280
const char* lpenv = getenv("LIBPATH");
73-
libpath << (lpenv != NULL ? lpenv : "");
81+
libpath << (lpenv != nullptr ? lpenv : "");
7482
libpath << ":" << p2 << "/lib";
7583
libpath << ":" << p << "/lib";
7684
libpath << ":" << p << "/lib.target";
7785
setenv("LIBPATH", libpath.str().c_str(), 1);
7886
return;
7987
}
8088
}
81-
fprintf(stderr, "Error: w_getpsent failed to find process id %d, " \
82-
"errno=%d.\n" \
83-
"Please report this error to IBM customer support.\n",
84-
mypid, errno);
89+
fprintf(stderr,
90+
"Error: w_getpsent failed to find process id %d, "
91+
"errno=%d.\n"
92+
"Please report this error to IBM customer support.\n",
93+
mypid,
94+
errno);
8595
}
8696
};
8797

0 commit comments

Comments
 (0)