@@ -38,14 +38,12 @@ class ErrorAsyncWorker : public Napi::AsyncWorker {
38
38
void Execute () override {}
39
39
void OnOK () override {
40
40
Napi::Env env = Env ();
41
-
42
41
Callback ().MakeCallback (Receiver ().Value (),
43
42
{error.Value (), env.Undefined ()});
44
43
}
45
44
46
45
void OnError (const Napi::Error &e) override {
47
46
Napi::Env env = Env ();
48
-
49
47
Callback ().MakeCallback (Receiver ().Value (), {e.Value (), env.Undefined ()});
50
48
}
51
49
@@ -108,7 +106,7 @@ Napi::Number ConsoleSync(const Napi::CallbackInfo &info) {
108
106
}
109
107
110
108
std::stringstream message;
111
- for (int i = 0 ; i < info.Length (); ++i) {
109
+ for (size_t i = 0 ; i < info.Length (); ++i) {
112
110
message << info[i].ToString ().Utf8Value ();
113
111
if (i < (info.Length () - 1 ))
114
112
message << " " ;
@@ -130,7 +128,7 @@ Napi::Value GetFileCcsid(const Napi::CallbackInfo &info) {
130
128
if (info[0 ].IsNumber ()) {
131
129
int fd = info[0 ].As <Napi::Number>();
132
130
struct stat st;
133
- int rc, err ;
131
+ int rc;
134
132
rc = fstat (fd, &st);
135
133
if (rc != 0 ) {
136
134
res.Set (" error" ,
@@ -140,10 +138,9 @@ Napi::Value GetFileCcsid(const Napi::CallbackInfo &info) {
140
138
res.Set (" ccsid" , st.st_tag .ft_ccsid );
141
139
}
142
140
} else {
143
- const char *tmp = info[0 ].ToString ().Utf8Value ().c_str ();
144
- strncpy (filename, tmp, 1024 );
141
+ strncpy (filename, info[0 ].ToString ().Utf8Value ().c_str (), 1024 );
145
142
struct stat st;
146
- int rc, err ;
143
+ int rc;
147
144
rc = stat (filename, &st);
148
145
if (rc != 0 ) {
149
146
res.Set (" error" , errstring (message, 1024 , errno, " stat error on file %s " ,
@@ -171,8 +168,7 @@ Napi::Value SetFileCcsid(const Napi::CallbackInfo &info) {
171
168
if (info[0 ].IsNumber ()) {
172
169
fd = info[0 ].As <Napi::Number>();
173
170
} else {
174
- const char *tmp = info[0 ].ToString ().Utf8Value ().c_str ();
175
- strncpy (filename, tmp, 1024 );
171
+ strncpy (filename, info[0 ].ToString ().Utf8Value ().c_str (), 1024 );
176
172
}
177
173
int text;
178
174
int ccsid;
@@ -235,7 +231,6 @@ Napi::Value GuessFileCcsid(const Napi::CallbackInfo &info) {
235
231
Napi::Object res = Napi::Object::New (env);
236
232
char message[1024 ];
237
233
char filename[1024 ];
238
- int ccsid = 0 ;
239
234
int fd = -1 ;
240
235
if (info.Length () < 1 ) {
241
236
Napi::Error::New (env, " Need file name or file descriptor as argument" )
@@ -247,8 +242,7 @@ Napi::Value GuessFileCcsid(const Napi::CallbackInfo &info) {
247
242
fd = info[0 ].As <Napi::Number>();
248
243
res.Set (" fd" , fd);
249
244
} else {
250
- const char *tmp = info[0 ].ToString ().Utf8Value ().c_str ();
251
- strncpy (filename, tmp, 1024 );
245
+ strncpy (filename, info[0 ].ToString ().Utf8Value ().c_str (), 1024 );
252
246
fd = open (filename, O_RDONLY);
253
247
if (-1 == fd) {
254
248
res.Set (" error" ,
0 commit comments