Skip to content

Commit

Permalink
Fix clang build warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaxun Yang <[email protected]>
  • Loading branch information
FlyGoat committed Jun 5, 2019
1 parent fe140fd commit d994c9f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
34 changes: 28 additions & 6 deletions argparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ argparse_getvalue(struct argparse *self, const struct argparse_option *opt,
int flags)
{
const char *s = NULL;
char buf[256];
buf[0] = 0;
char *pbuf = buf;

if (!opt->value)
goto skipped;
switch (opt->type) {
Expand Down Expand Up @@ -93,8 +97,14 @@ argparse_getvalue(struct argparse *self, const struct argparse_option *opt,
} else {
argparse_error(self, opt, "requires a value", flags);
}
if (errno)
argparse_error(self, opt, strerror(errno), flags);
if (errno){
#ifdef _WIN32
strerror_s(buf, sizeof(buf), errno);
#else
strerror_r(errno, buf, sizeof(buf));
#endif
argparse_error(self, opt, pbuf, flags);
}
if (s[0] != '\0')
argparse_error(self, opt, "expects an integer value", flags);
break;
Expand All @@ -109,8 +119,14 @@ argparse_getvalue(struct argparse *self, const struct argparse_option *opt,
} else {
argparse_error(self, opt, "requires a value", flags);
}
if (errno)
argparse_error(self, opt, strerror(errno), flags);
if (errno){
#ifdef _WIN32
strerror_s(buf, sizeof(buf), errno);
#else
strerror_r(errno, buf, sizeof(buf));
#endif
argparse_error(self, opt, pbuf, flags);
}
if (s[0] != '\0')
argparse_error(self, opt, "expects an unsigned 32-bit integer value", flags);
break;
Expand All @@ -125,8 +141,14 @@ argparse_getvalue(struct argparse *self, const struct argparse_option *opt,
} else {
argparse_error(self, opt, "requires a value", flags);
}
if (errno)
argparse_error(self, opt, strerror(errno), flags);
if (errno){
#ifdef _WIN32
strerror_s(buf, sizeof(buf), errno);
#else
strerror_r(errno, buf, sizeof(buf));
#endif
argparse_error(self, opt, pbuf, flags);
}
if (s[0] != '\0')
argparse_error(self, opt, "expects a numerical value", flags);
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/winring0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern "C" pci_obj_t init_pci_obj(){
InitializeOls();
if(GetDllStatus() == 0)
return &nb_pci_obj;
printf("WinRing0 Err: 0x%x",GetDllStatus());
printf("WinRing0 Err: 0x%lx",GetDllStatus());
return NULL;
}

Expand Down

0 comments on commit d994c9f

Please sign in to comment.