[PATCH] don't end "error(..." diagnostic with "\n"

Jim Meyering jim at meyering.net
Tue Sep 28 09:32:32 UTC 2010


Actually, that command missed a few
where the string was on the line following the function name.
I did those manually.

>From bc81e99ff8ea7f910ee48be11c4aca485794ec6f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 28 Sep 2010 10:32:45 +0200
Subject: [PATCH] don't end "error(..." diagnostic with "\n"

Fix them all by running this command:
git grep -l 'error.*\\n'|xargs perl -pi -e 's/(\berror ?\(.*)\\n"/$1"/'
---
 backend.c |   18 ++++++++--------
 proxy.c   |   67 ++++++++++++++++++++++++++++++-------------------------------
 2 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/backend.c b/backend.c
index fce5bb9..e76a469 100644
--- a/backend.c
+++ b/backend.c
@@ -249,7 +249,7 @@ s3_put_child (void * ctx)
 		llen = strtoll(clen,NULL,10);
 	}
 	else {
-		error (0, 0, "missing Content-Length\n");
+		error (0, 0, "missing Content-Length");
 		llen = (curl_off_t)MHD_SIZE_UNKNOWN;
 	}

@@ -320,7 +320,7 @@ s3_init_tmpfile (char *value)
 			}
 			else {
 				error (0, errno,
-				       "invalid write length %zd in %s\n",
+				       "invalid write length %zd in %s",
 				       written, __func__);
 			}
 			unlink(path);
@@ -378,7 +378,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
 	if (!api_key) {
 		api_key = (char *)prov->username;
 		if (!api_key) {
-			error (0, 0, "missing EC2 API key\n");
+			error (0, 0, "missing EC2 API key");
 			goto cleanup;
 		}
 	}
@@ -387,7 +387,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
 	if (!api_secret) {
 		api_secret = (char *)prov->password;
 		if (!prov->password) {
-			error (0, 0, "missing EC2 API key\n");
+			error (0, 0, "missing EC2 API key");
 			goto cleanup;
 		}
 	}
@@ -402,7 +402,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
 	else {
 		ami_cert = get_provider_value(prov->index,"ami-cert");
 		if (!ami_cert) {
-			error (0, 0, "missing EC2 AMI cert\n");
+			error (0, 0, "missing EC2 AMI cert");
 			goto cleanup;
 		}
 	}
@@ -417,7 +417,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
 	else {
 		ami_key = get_provider_value(prov->index,"ami-key");
 		if (!ami_key) {
-			error (0, 0, "missing EC2 AMI key\n");
+			error (0, 0, "missing EC2 AMI key");
 			goto cleanup;
 		}
 	}
@@ -426,7 +426,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
 	if (!ami_uid) {
 		ami_uid = get_provider_value(prov->index,"ami-uid");
 		if (!ami_uid) {
-			error (0, 0, "missing EC2 AMI uid\n");
+			error (0, 0, "missing EC2 AMI uid");
 			goto cleanup;
 		}
 	}
@@ -604,7 +604,7 @@ curl_put_child (void * ctx)
 		llen = strtoll(clen,NULL,10);
 	}
 	else {
-		error (0, 0, "missing Content-Length\n");
+		error (0, 0, "missing Content-Length");
 		llen = (curl_off_t)MHD_SIZE_UNKNOWN;
 	}

@@ -773,7 +773,7 @@ fs_init (void)
 {
 	DPRINTF("changing directory to %s\n",local_path);
 	if (chdir(local_path) < 0) {
-		error(0,errno,"chdir failed, unsafe to continue\n");
+		error(0,errno,"chdir failed, unsafe to continue");
 		exit(!0); /* Value doesn't matter, as long as it's not zero. */
 	}
 }
diff --git a/proxy.c b/proxy.c
index 5aebcae..5138fc6 100644
--- a/proxy.c
+++ b/proxy.c
@@ -114,20 +114,20 @@ validate_server (unsigned int i)

 	server = json_array_get(config,i);
 	if (!json_is_object(server)) {
-		error(0,0,"config elem %u: missing object\n",i);
+		error(0,0,"config elem %u: missing object",i);
 		return 0;
 	}

 	elem = json_object_get(server,"name");
 	if (!json_is_string(elem)) {
-		error(0,0,"config elem %u: missing name\n",i);
+		error(0,0,"config elem %u: missing name",i);
 		return 0;
 	}
 	name = json_string_value(elem);

 	elem = json_object_get(server,"type");
 	if (!json_is_string(elem)) {
-		error(0,0,"config elem %u (%s): missing type\n",i,name);
+		error(0,0,"config elem %u (%s): missing type",i,name);
 		return 0;
 	}
 	type = json_string_value(elem);
@@ -142,20 +142,20 @@ validate_server (unsigned int i)
 		needs = NEED_PATH;
 	}
 	else {
-		error(0,0,"config elem %u (%s): bad type\n",i,name);
+		error(0,0,"config elem %u (%s): bad type",i,name);
 		return 0;
 	}

 	if (needs & NEED_SERVER) {
 		elem = json_object_get(server,"host");
 		if (!json_is_string(elem)) {
-			error(0,0,"config elem %u (%s): missing host\n",
+			error(0,0,"config elem %u (%s): missing host",
 				i,name);
 			return 0;
 		}
 		elem = json_object_get(server,"port");
 		if (!json_is_integer(elem)) {
-			error(0,0,"config elem %u (%s): missing port\n",
+			error(0,0,"config elem %u (%s): missing port",
 				i,name);
 			return 0;
 		}
@@ -164,15 +164,14 @@ validate_server (unsigned int i)
 	if (needs & NEED_CREDS) {
 		elem = json_object_get(server,"key");
 		if (!json_is_string(elem)) {
-			error(0,0,"config elem %u (%s): missing key\n",
-				i, name);
+			error(0,0,"config elem %u (%s): missing key",
+			      i, name);
 			return 0;
 		}
 		elem = json_object_get(server,"secret");
 		if (!json_is_string(elem)) {
-			error(0,0,
-				"config elem %u (%s): missing secret\n",
-				i, name);
+			error(0,0, "config elem %u (%s): missing secret",
+			      i, name);
 			return 0;
 		}
 	}
@@ -180,8 +179,8 @@ validate_server (unsigned int i)
 	if (needs & NEED_PATH) {
 		elem = json_object_get(server,"path");
 		if (!json_is_string(elem)) {
-			error(0,0,"config elem %u (%s): missing path\n",
-				i, name);
+			error(0,0,"config elem %u (%s): missing path",
+			      i, name);
 			return 0;
 		}
 	}
@@ -236,12 +235,12 @@ parse_config (void)

 	config = json_load_file(cfg_file,&err);
 	if (!config) {
-		error(0,0,"JSON error on line %d: %s\n",err.line,err.text);
+		error(0,0,"JSON error on line %d: %s",err.line,err.text);
 		return NULL;
 	}

 	if (json_typeof(config) != JSON_ARRAY) {
-		error(0,0,"config should be a JSON array\n");
+		error(0,0,"config should be a JSON array");
 		goto err;
 	}

@@ -357,7 +356,7 @@ proxy_repl_prod (void *ctx)
 	chars = snprintf(addr,ADDR_SIZE,
 		"http://%s:%u/%s",proxy_host,proxy_port,item->path);
 	if (chars >= ADDR_SIZE) {
-		error(0,0,"path too long in %s\n",__func__);
+		error(0,0,"path too long in %s",__func__);
 		goto done;
 	}
 	DPRINTF("replicating from %s\n",addr);
@@ -366,7 +365,7 @@ proxy_repl_prod (void *ctx)
 		chars = snprintf(svc_acc,SVC_ACC_SIZE,"%s:%u",
 			proxy_host,proxy_port);
 		if (chars >= SVC_ACC_SIZE) {
-			error(0,0,"svc_acc too long in %s\n",__func__);
+			error(0,0,"svc_acc too long in %s",__func__);
 			goto done;
 		}
 		hstor = hstor_new(svc_acc,proxy_host,
@@ -464,19 +463,19 @@ get_cloudfiles_token (json_t *server, const char *host, unsigned int port,

 	chars = snprintf(addr,ADDR_SIZE,"https://%s:%u/v1.0",host,port);
 	if (chars >= ADDR_SIZE) {
-		error(0,0,"API URL too long in %s\n",__func__);
+		error(0,0,"API URL too long in %s",__func__);
 		return NULL;
 	}

 	chars = snprintf(auth_user,HEADER_SIZE,"X-Auth-User: %s",user);
 	if (chars >= HEADER_SIZE) {
-		error(0,0,"auth_user too long in %s\n",__func__);
+		error(0,0,"auth_user too long in %s",__func__);
 		return NULL;
 	}

 	chars = snprintf(auth_key,HEADER_SIZE,"X-Auth-Key: %s",key);
 	if (chars >= HEADER_SIZE) {
-		error(0,0,"auth_key too long in %s\n",__func__);
+		error(0,0,"auth_key too long in %s",__func__);
 		return NULL;
 	}

@@ -543,7 +542,7 @@ proxy_repl_cons (void *ctx)
 			item->path);
 		chars = snprintf(svc_acc,SVC_ACC_SIZE,"%s:%u",s_host,s_port);
 		if (chars >= SVC_ACC_SIZE) {
-			error(0,0,"svc_acc too long in %s\n",__func__);
+			error(0,0,"svc_acc too long in %s",__func__);
 			return THREAD_FAILED;
 		}
 		hstor = hstor_new(svc_acc,s_host,s_key,s_secret);
@@ -567,7 +566,7 @@ proxy_repl_cons (void *ctx)
 			chars = snprintf(addr,ADDR_SIZE,"%s/%s",
 				s_host,item->path);
 			if (chars >= ADDR_SIZE) {
-				error(0,0,"CF path too long in %s\n",__func__);
+				error(0,0,"CF path too long in %s",__func__);
 				return THREAD_FAILED;
 			}
 			DPRINTF("replicating %zu to %s (CF)\n",item->size,
@@ -577,7 +576,7 @@ proxy_repl_cons (void *ctx)
 			chars = snprintf(addr,ADDR_SIZE,"http://%s:%u/%s",
 				s_host,s_port,item->path);
 			if (chars >= ADDR_SIZE) {
-				error(0,0,"HTTP path too long in %s\n",
+				error(0,0,"HTTP path too long in %s",
 					__func__);
 				return THREAD_FAILED;
 			}
@@ -594,7 +593,7 @@ proxy_repl_cons (void *ctx)
 			chars = snprintf(auth_hdr,HEADER_SIZE,
 				"X-Auth-Token: %s",token_str);
 			if (chars >= HEADER_SIZE) {
-				error(0,0,"auth_token too long in %s\n",
+				error(0,0,"auth_token too long in %s",
 					__func__);
 				return THREAD_FAILED;
 			}
@@ -654,7 +653,7 @@ repl_worker_del (const repl_item *item)
 			item->path, s_host, s_port);
 		chars = snprintf(svc_acc,SVC_ACC_SIZE,"%s:%u",s_host,s_port);
 		if (chars >= SVC_ACC_SIZE) {
-			error(0,0,"svc_acc too long in %s\n",__func__);
+			error(0,0,"svc_acc too long in %s",__func__);
 			return;
 		}
 		/* TBD: check return */
@@ -671,7 +670,7 @@ repl_worker_del (const repl_item *item)
 		chars = snprintf(addr,ADDR_SIZE,"http://%s:%d%s",
 			s_host,s_port,item->path);
 		if (chars >= ADDR_SIZE) {
-			error(0,0,"path too long in %s\n",__func__);
+			error(0,0,"path too long in %s",__func__);
 			return;
 		}
 		curl = curl_easy_init();
@@ -711,14 +710,14 @@ repl_worker_bcreate (repl_item *item)
 			__func__, item->path, s_host, s_port);
 		chars = snprintf(svc_acc,SVC_ACC_SIZE,"%s:%u",s_host,s_port);
 		if (chars >= SVC_ACC_SIZE) {
-			error(0,0,"svc_acc too long in %s\n",__func__);
+			error(0,0,"svc_acc too long in %s",__func__);
 			return;
 		}
 		/* TBD: check return */
 		hstor = hstor_new(svc_acc,s_host,s_key,s_secret);
 		assert (item->path);
 		if (!hstor_add_bucket(hstor,item->path)) {
-			error(0,0,"bucket create failed for %s\n",
+			error(0,0,"bucket create failed for %s",
 				item->path);
 		}
 		hstor_free(hstor);
@@ -729,7 +728,7 @@ repl_worker_bcreate (repl_item *item)
 		chars = snprintf(addr,ADDR_SIZE,"http://%s:%d/%s",
 			s_host,s_port,item->path);
 		if (chars >= ADDR_SIZE) {
-			error(0,0,"path too long in %s\n",__func__);
+			error(0,0,"path too long in %s",__func__);
 			return;
 		}
 		curl = curl_easy_init();
@@ -785,7 +784,7 @@ repl_worker (void *notused ATTRIBUTE_UNUSED)
 			repl_worker_bcreate(item);
 			break;
 		default:
-			error(0,0,"bad repl type %d (url=%s) skipped\n",
+			error(0,0,"bad repl type %d (url=%s) skipped",
 				item->type, item->path);
 		}
 		free(item->path);
@@ -838,7 +837,7 @@ replicate (const char *url, size_t size, const char *policy)

 	url2 = strdup(url);
 	if (!url2) {
-		error(0,0,"could not parse url %s\n",url);
+		error(0,0,"could not parse url %s",url);
 		return;
 	}
 	qctx.cur_bucket = strtok_r(url2,"/",&stctx);
@@ -877,14 +876,14 @@ replicate (const char *url, size_t size, const char *policy)
 		DPRINTF("REPLICATING %s to %u\n",url,i);
 		item = malloc(sizeof(*item));
 		if (!item) {
-			error(0,errno,"could not create repl_item for %s\n",
+			error(0,errno,"could not create repl_item for %s",
 			      url);
 			break;
 		}
 		item->type = REPL_PUT;
 		item->path = strdup(url);
 		if (!item->path) {
-			error(0,errno,"could not create repl_item for %s\n",
+			error(0,errno,"could not create repl_item for %s",
 			      url);
 			break;
 		}
@@ -920,7 +919,7 @@ replicate_namespace_action (const char *name, repl_t action)
 		DPRINTF("replicating delete(%s) on %u\n",name,i);
 		item = malloc(sizeof(*item));
 		if (!item) {
-			error(0,errno,"could not create repl_item for %s\n",
+			error(0,errno,"could not create repl_item for %s",
 			      name);
 			return;
 		}
--
1.7.3.293.gca9a76


More information about the iwhd-devel mailing list