---------- Forwarded message ----------
Date: Sun, 13 Sep 2009 10:32:49 +0200 (CEST)
From: Julia Lawall <ju...@diku.dk>
Reply-To: openssl-dev@openssl.org
To: openssl-dev@openssl.org, Rene Rydhof Hansen <r...@cs.aau.dk>,
    z...@google.com, Gilles Muller - lip6 <gilles.mul...@lip6.fr>
Subject: [PATCH] use of ENGINE_ctrl

The function ENGINE_ctrl sometimes returns 0 to indicate an error and 
sometimes returns -1.  In each of the cases below, the goal seems to be to 
return 1 only in the case of success.  Therefore the result of ENGINE_ctrl 
should be tested using > 0.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@expression@
expression list args;
@@

-   ENGINE_ctrl(args) == 0
+   ENGINE_ctrl(args) <= 0
    || ...

@expression@
expression list args;
@@

-   ENGINE_ctrl(args) != 0
+   ENGINE_ctrl(args) > 0
    || ...
// </smpl>

---

diff -u -p a/crypto/engine/eng_ctrl.c b/crypto/engine/eng_ctrl.c
--- a/crypto/engine/eng_ctrl.c 2005-05-11 05:45:27.000000000 +0200
+++ b/crypto/engine/eng_ctrl.c 2009-09-12 11:25:47.000000000 +0200
@@ -280,7 +280,7 @@ int ENGINE_ctrl_cmd(ENGINE *e, const cha
                }
        /* Force the result of the control command to 0 or 1, for the reasons
         * mentioned before. */
-        if (ENGINE_ctrl(e, num, i, p, f))
+        if (ENGINE_ctrl(e, num, i, p, f) > 0)
                 return 1;
         return 0;
         }
@@ -345,7 +345,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, co
                 * usage of these commands is consistent across applications and
                 * that certain applications don't understand it one way, and
                 * others another. */
-               if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL))
+               if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0)
                        return 1;
                return 0;
                }
@@ -360,7 +360,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, co
        if(flags & ENGINE_CMD_FLAG_STRING)
                {
                /* Same explanation as above */
-               if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL))
+               if(ENGINE_ctrl(e, num, 0, (void *)arg, NULL) > 0)
                        return 1;
                return 0;
                }
@@ -383,7 +383,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, co
                }
        /* Force the result of the control command to 0 or 1, for the reasons
         * mentioned before. */
-       if(ENGINE_ctrl(e, num, l, NULL, NULL))
+       if(ENGINE_ctrl(e, num, l, NULL, NULL) > 0)
                return 1;
        return 0;
        }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to