changeset 1061:38c3ca0cea50

nvl_alloc returns a negated errno on error Checking for NULL is useless since nvl_alloc never returns NULL. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 12 Oct 2020 11:51:13 -0400
parents 226dc304f397
children 3ca4f367c752
files comment.c post_nv.c req.c sidebar.c vars.c
diffstat 5 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/comment.c	Wed Aug 26 09:45:12 2020 -0400
+++ b/comment.c	Mon Oct 12 11:51:13 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2009-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -433,8 +433,8 @@
 	}
 
 	qs = nvl_alloc();
-	if (!qs) {
-		DBG("failed to allocate nvlist");
+	if (IS_ERR(qs)) {
+		DBG("failed to allocate nvlist: %s", xstrerror(PTR_ERR(qs)));
 		return INTERNAL_ERR;
 	}
 
--- a/post_nv.c	Wed Aug 26 09:45:12 2020 -0400
+++ b/post_nv.c	Mon Oct 12 11:51:13 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2009-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -73,8 +73,8 @@
 		struct nvlist *c;
 
 		c = nvl_alloc();
-		if (!c) {
-			ret = -ENOMEM;
+		if (IS_ERR(c)) {
+			ret = PTR_ERR(c);
 			goto err;
 		}
 
@@ -129,8 +129,8 @@
 	}
 
 	out = nvl_alloc();
-	if (!out) {
-		ret = -ENOMEM;
+	if (IS_ERR(out)) {
+		ret = PTR_ERR(out);
 		goto err;
 	}
 
--- a/req.c	Wed Aug 26 09:45:12 2020 -0400
+++ b/req.c	Mon Oct 12 11:51:13 2020 -0400
@@ -132,7 +132,7 @@
 	 * allocate a log entry & store some misc info
 	 */
 	logentry = nvl_alloc();
-	if (!logentry)
+	if (IS_ERR(logentry))
 		goto err;
 	nvl_set_int(logentry, "time-stamp", now);
 	nvl_set_int(logentry, "pid", getpid());
@@ -142,7 +142,7 @@
 	 * store the version info
 	 */
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		goto err_free;
 	nvl_set_str(tmp, "blahgd", STATIC_STR(version_string));
 	nvl_set_str(tmp, "libjeffpc", STATIC_STR(jeffpc_version));
@@ -152,7 +152,7 @@
 	 * store the request
 	 */
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		goto err_free;
 	nvl_set_int(tmp, "id", scgi->id);
 	nvl_set_nvl(tmp, "headers", nvl_getref(scgi->request.headers));
@@ -170,7 +170,7 @@
 	 * store the response
 	 */
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		goto err_free;
 	nvl_set_int(tmp, "status", scgi->response.status);
 	nvl_set_nvl(tmp, "headers", nvl_getref(scgi->response.headers));
@@ -181,7 +181,7 @@
 	 * store the stats
 	 */
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		goto err_free;
 	nvl_set_time(tmp, "conn-selected", scgi->conn_stats.selected_time);
 	nvl_set_time(tmp, "conn-accepted", scgi->conn_stats.accepted_time);
@@ -197,7 +197,7 @@
 	 * store the options
 	 */
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		goto err_free;
 	nvl_set_int(tmp, "index-stories", req->opts.index_stories);
 	nvl_set_nvl(logentry, "options", tmp);
--- a/sidebar.c	Wed Aug 26 09:45:12 2020 -0400
+++ b/sidebar.c	Mon Oct 12 11:51:13 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2013-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -76,7 +76,7 @@
 		return;
 
 	tmp = nvl_alloc();
-	if (!tmp)
+	if (IS_ERR(tmp))
 		return;
 
 	if ((ret = nvl_set_str(tmp, "name", str_getref(name))))
--- a/vars.c	Wed Aug 26 09:45:12 2020 -0400
+++ b/vars.c	Mon Oct 12 11:51:13 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2013-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -31,7 +31,7 @@
 static void __init_scope(struct vars *vars)
 {
 	vars->scopes[vars->cur] = nvl_alloc();
-	ASSERT(vars->scopes[vars->cur]);
+	ASSERT(!IS_ERR(vars->scopes[vars->cur]));
 }
 
 static void __free_scope(struct nvlist *scope)