Skip to contentSkip to conversation

error: passing a negative value to an os_errno is wrong

PATCH In review SeokYeon Hwang 3 participants 3 messages Nov 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 error: passing a negative value to an os_errno is wrong

Added 'assert(os_errno >= 0)' in 'error_set_errno()'.

---
 util/error.c | 1 +
 1 file changed, 1 insertion(+)
util/error.c +1 -0
index 2ace0d8..6c9d995 100644
@@ -62,6 +62,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
         return;
     }
     assert(*errp == NULL);
+    assert(os_errno >= 0);
 
     err = g_malloc0(sizeof(*err));
 
Signature · 1 line
2.1.0
Reviewed-by on v4 1/1
#1 lore raw
Quoted 12 lines · SeokYeon Hwang

Added 'assert(os_errno >= 0)' in 'error_set_errno()'.

---
 util/error.c | 1 +
 1 file changed, 1 insertion(+)
util/error.c +0 -0
index 2ace0d8..6c9d995 100644

util/error.c void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, · line 67

Quoted 6 lines
util/error.c +1 -0
@@ -62,6 +62,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
         return;
     }
     assert(*errp == NULL);
+    assert(os_errno >= 0);
 
     err = g_malloc0(sizeof(*err));

Too risky for 2.2 at this stage, but fine for 2.3.

Reviewed-by on v4 1/1
#2 lore raw
In reply to SeokYeon Hwang
Quoted 12 lines · SeokYeon Hwang

Added 'assert(os_errno >= 0)' in 'error_set_errno()'.

---
  util/error.c | 1 +
  1 file changed, 1 insertion(+)
util/error.c +0 -0
index 2ace0d8..6c9d995 100644

util/error.c void error_set_errno(Error **errp, int os_errno, ErrorClass err_class, · line 68

Quoted 7 lines
util/error.c +1 -0
@@ -62,6 +62,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
          return;
      }
      assert(*errp == NULL);
+    assert(os_errno >= 0);
 
      err = g_malloc0(sizeof(*err));