Skip to content

Commit 27bddd0

Browse files
committed
Fix warnings
1 parent a6af9d8 commit 27bddd0

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Note: -Bsymbolic is necessary to ensure new/delete goes through the overrides in new.cpp and is tracked
33
LD_FLAGS+= -L$(V8_PATH)/out.gn/x64.release.sample/obj/ -lv8_monolith -lpthread -lstdc++fs -static-libstdc++ -Wl,-Bsymbolic
4-
CXX_FLAGS+= -std=c++17 -fvisibility=hidden -fPIC -O2 -g -isystem $(V8_PATH)/include -DV8_COMPRESS_POINTERS
4+
CXX_FLAGS+= -Wall -Wextra -std=c++17 -fvisibility=hidden -fPIC -O2 -g -isystem $(V8_PATH)/include -DV8_COMPRESS_POINTERS
55

66
MODULE_OBJS = js.o module.o sha256.o new.o
77

js.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ std::experimental::filesystem::path find_module(std::experimental::filesystem::p
113113
}
114114
wdir = wdir.parent_path();
115115
} while (!wdir.empty());
116+
117+
return name;
116118
}
117119

118120
/*static*/ void JSContext::RequireCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
@@ -199,9 +201,9 @@ std::experimental::filesystem::path find_module(std::experimental::filesystem::p
199201
}
200202

201203
bool flagT;
202-
auto maybeInstantiated = module->InstantiateModule(context, [](v8::Local<v8::Context> context, // "main.mjs"
203-
v8::Local<v8::String> specifier, // "some thing"
204-
v8::Local<v8::Module> referrer) -> v8::MaybeLocal<v8::Module> {
204+
auto maybeInstantiated = module->InstantiateModule(context, [](v8::Local<v8::Context> /*context*/, // "main.mjs"
205+
v8::Local<v8::String> /*specifier*/, // "some thing"
206+
v8::Local<v8::Module> /*referrer*/) -> v8::MaybeLocal<v8::Module> {
205207
return v8::Local<v8::Module>();
206208
});
207209
if (!maybeInstantiated.To(&flagT) || !flagT)

module.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void KeyDBExecuteCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
123123
v8::String::Utf8Value fnName(isolate, vfnName);
124124

125125
std::vector<RedisModuleString*> vecstrs;
126-
for (size_t iarg = 1; iarg < args.Length(); ++iarg)
126+
for (int iarg = 1; iarg < args.Length(); ++iarg)
127127
{
128128
v8::String::Utf8Value argument(isolate, args[iarg]);
129129
vecstrs.push_back(RedisModule_CreateString(g_ctx, *argument, argument.length()));
@@ -331,11 +331,11 @@ int evaljs_command(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
331331
return REDISMODULE_OK;
332332
}
333333

334-
int run_startup_script(RedisModuleCtx *ctx, const char *rgchPath, size_t cchPath)
334+
int run_startup_script(RedisModuleCtx *ctx, const char *szPath)
335335
{
336336
KeyDBContext ctxsav(ctx);
337337

338-
std::ifstream file(rgchPath, std::ios::binary | std::ios::ate);
338+
std::ifstream file(szPath, std::ios::binary | std::ios::ate);
339339
std::streamsize size = file.tellg();
340340
if (size == -1)
341341
{
@@ -365,12 +365,19 @@ int run_startup_script(RedisModuleCtx *ctx, const char *rgchPath, size_t cchPath
365365
return REDISMODULE_OK;
366366
}
367367

368+
int ReplyWithCString(RedisModuleCtx *ctx, const char *sz)
369+
{
370+
return RedisModule_ReplyWithStringBuffer(ctx, sz, strlen(sz));
371+
}
372+
368373
extern "C" int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
369374
{
370-
printf("argc: %d\n", argc);
371375
if (RedisModule_Init(ctx,"modjs",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR)
372376
return REDISMODULE_ERR;
373377

378+
if (RedisModule_ReplyWithCString == nullptr)
379+
RedisModule_ReplyWithCString = ReplyWithCString;
380+
374381
if (RedisModule_CreateCommand(ctx,"evaljs", evaljs_command,"write deny-oom random",0,0,0) == REDISMODULE_ERR)
375382
return REDISMODULE_ERR;
376383

@@ -389,7 +396,7 @@ extern "C" int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisMo
389396
path.remove_filename();
390397
path /= "bootstrap.js";
391398
std::string strPath = path.string();
392-
if (run_startup_script(ctx, strPath.data(), strPath.size()) == REDISMODULE_ERR)
399+
if (run_startup_script(ctx, strPath.c_str()) == REDISMODULE_ERR)
393400
{
394401
RedisModule_Log(ctx, "warning", "failed to run bootstrap.js, ensure this is located in the same location as the .so");
395402
return REDISMODULE_ERR;
@@ -408,7 +415,7 @@ extern "C" int __attribute__((visibility("default"))) RedisModule_OnLoad(RedisMo
408415
size_t cchPath;
409416
const char *rgchPath = RedisModule_StringPtrLen(argv[iarg], &cchPath);
410417

411-
if (run_startup_script(ctx, rgchPath, cchPath) == REDISMODULE_ERR)
418+
if (run_startup_script(ctx, rgchPath) == REDISMODULE_ERR)
412419
return REDISMODULE_ERR;
413420
}
414421

0 commit comments

Comments
 (0)