Skip to content

Commit 9ae36d6

Browse files
fix warnings
1 parent 31cec89 commit 9ae36d6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

addon.cc

+6-12
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ class ErrorAsyncWorker : public Napi::AsyncWorker {
3838
void Execute() override {}
3939
void OnOK() override {
4040
Napi::Env env = Env();
41-
4241
Callback().MakeCallback(Receiver().Value(),
4342
{error.Value(), env.Undefined()});
4443
}
4544

4645
void OnError(const Napi::Error &e) override {
4746
Napi::Env env = Env();
48-
4947
Callback().MakeCallback(Receiver().Value(), {e.Value(), env.Undefined()});
5048
}
5149

@@ -108,7 +106,7 @@ Napi::Number ConsoleSync(const Napi::CallbackInfo &info) {
108106
}
109107

110108
std::stringstream message;
111-
for (int i = 0; i < info.Length(); ++i) {
109+
for (size_t i = 0; i < info.Length(); ++i) {
112110
message << info[i].ToString().Utf8Value();
113111
if (i < (info.Length() - 1))
114112
message << " ";
@@ -130,7 +128,7 @@ Napi::Value GetFileCcsid(const Napi::CallbackInfo &info) {
130128
if (info[0].IsNumber()) {
131129
int fd = info[0].As<Napi::Number>();
132130
struct stat st;
133-
int rc, err;
131+
int rc;
134132
rc = fstat(fd, &st);
135133
if (rc != 0) {
136134
res.Set("error",
@@ -140,10 +138,9 @@ Napi::Value GetFileCcsid(const Napi::CallbackInfo &info) {
140138
res.Set("ccsid", st.st_tag.ft_ccsid);
141139
}
142140
} 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);
145142
struct stat st;
146-
int rc, err;
143+
int rc;
147144
rc = stat(filename, &st);
148145
if (rc != 0) {
149146
res.Set("error", errstring(message, 1024, errno, "stat error on file %s ",
@@ -171,8 +168,7 @@ Napi::Value SetFileCcsid(const Napi::CallbackInfo &info) {
171168
if (info[0].IsNumber()) {
172169
fd = info[0].As<Napi::Number>();
173170
} 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);
176172
}
177173
int text;
178174
int ccsid;
@@ -235,7 +231,6 @@ Napi::Value GuessFileCcsid(const Napi::CallbackInfo &info) {
235231
Napi::Object res = Napi::Object::New(env);
236232
char message[1024];
237233
char filename[1024];
238-
int ccsid = 0;
239234
int fd = -1;
240235
if (info.Length() < 1) {
241236
Napi::Error::New(env, "Need file name or file descriptor as argument")
@@ -247,8 +242,7 @@ Napi::Value GuessFileCcsid(const Napi::CallbackInfo &info) {
247242
fd = info[0].As<Napi::Number>();
248243
res.Set("fd", fd);
249244
} 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);
252246
fd = open(filename, O_RDONLY);
253247
if (-1 == fd) {
254248
res.Set("error",

filescan.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int filescan(char *errmsg, size_t sz, int fd) {
264264
errstring(errmsg, sz, errno, "lseek error on fd %d", fd);
265265
return -1;
266266
}
267-
int rc = lseek(fd, 0, SEEK_SET);
267+
original = lseek(fd, 0, SEEK_SET);
268268
if (-1 == original) {
269269
errstring(errmsg, sz, errno, "lseek error on fd %d", fd);
270270
return -1;

0 commit comments

Comments
 (0)