Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some return values ignored #271

Open
jorge-leon opened this issue Jul 10, 2023 · 1 comment
Open

Some return values ignored #271

jorge-leon opened this issue Jul 10, 2023 · 1 comment

Comments

@jorge-leon
Copy link

This is just to report a couple of ignored return values reported by the compiler.

The git diff output below shows their locations as well as a method to silence the warnings found here: https://stackoverflow.com/questions/11888594/ignoring-return-values-in-c

$ git diff -U0
diff --git a/jim-aio.c b/jim-aio.c
index 093457f..a18334b 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -1599 +1599 @@ static int aio_cmd_sync(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-    fsync(af->fd);
+    (void)(fsync(af->fd)+1);
diff --git a/jim-exec.c b/jim-exec.c
index 343d5e1..ef34fba 100644
--- a/jim-exec.c
+++ b/jim-exec.c
@@ -1059 +1059 @@ badargs:
-                dup2(inputId, fileno(stdin));
+             (void)(dup2(inputId, fileno(stdin))+1);
@@ -1063 +1063 @@ badargs:
-                dup2(outputId, fileno(stdout));
+             (void)(dup2(outputId, fileno(stdout))+1);
@@ -1069 +1069 @@ badargs:
-                dup2(errorId, fileno(stderr));
+             (void)(dup2(errorId, fileno(stderr))+1);
diff --git a/jimiocompat.c b/jimiocompat.c
index 8e7f3f2..af1c006 100644
--- a/jimiocompat.c
+++ b/jimiocompat.c
@@ -234 +234 @@ int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template, int unli
-        remove(Jim_String(filenameObj));
+      (void)(remove(Jim_String(filenameObj))+1);
diff --git a/linenoise.c b/linenoise.c
index 8b628fe..13956af 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -707 +707 @@ fatal:
-        atexit(linenoiseAtExit);
+      (void)(atexit(linenoiseAtExit)+1);
(END)
+             (void)(dup2(errorId, fileno(stderr))+1);
diff --git a/jim-signal.c b/jim-signal.c
index e25a276..bbda87c 100644
--- a/jim-signal.c
+++ b/jim-signal.c
@@ -7 +7 @@
-#include <string.h>
+#include <strings.h>
diff --git a/jimiocompat.c b/jimiocompat.c
index 8e7f3f2..af1c006 100644
--- a/jimiocompat.c
+++ b/jimiocompat.c
@@ -234 +234 @@ int Jim_MakeTempFile(Jim_Interp *interp, const char *filename_template, int unli
-        remove(Jim_String(filenameObj));
+      (void)(remove(Jim_String(filenameObj))+1);
diff --git a/linenoise.c b/linenoise.c
index 8b628fe..13956af 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -707 +707 @@ fatal:
-        atexit(linenoiseAtExit);
+      (void)(atexit(linenoiseAtExit)+1);

@msteveb
Copy link
Owner

msteveb commented Jul 11, 2023

What compiler/platform/build options are you using? What are some sample warning messages?

I prefer not to clutter the code just to keep the compiler happy if possible (and it's a moving target as compilers change).
Something like (void)(remove(Jim_String(filenameObj))+1); just seems to obscure the code.

If we have to do it, I'd probably prefer something like this from linenoise:

linenoise.c:#define IGNORE_RC(EXPR) if (EXPR) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants