public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/daemons/common daemon-client.c daemon-ser ...
@ 2011-08-31 12:18 mornfall
  0 siblings, 0 replies; 3+ messages in thread
From: mornfall @ 2011-08-31 12:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2011-08-31 12:18:40

Modified files:
	daemons/common : daemon-client.c daemon-server.c daemon-shared.c 

Log message:
	Fix warnings in daemons/common.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5

--- LVM2/daemons/common/daemon-client.c	2011/08/30 15:42:56	1.6
+++ LVM2/daemons/common/daemon-client.c	2011/08/31 12:18:40	1.7
@@ -4,6 +4,7 @@
 #include <sys/socket.h>
 #include <string.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <assert.h>
 #include <errno.h> // ENOMEM
 
@@ -53,7 +54,7 @@
 
 void daemon_reply_destroy(daemon_reply r) {
 	if (r.cft)
-		destroy_config_tree(r.cft);
+		dm_config_destroy(r.cft);
 }
 
 daemon_reply daemon_send_simple(daemon_handle h, char *id, ...)
--- LVM2/daemons/common/daemon-server.c	2011/08/31 11:31:58	1.11
+++ LVM2/daemons/common/daemon-server.c	2011/08/31 12:18:40	1.12
@@ -218,14 +218,14 @@
 	client_handle client;
 };
 
-int buffer_rewrite(char **buf, const char *format, const char *string) {
+static int buffer_rewrite(char **buf, const char *format, const char *string) {
 	char *old = *buf;
 	dm_asprintf(buf, format, *buf, string);
 	dm_free(old);
 	return 0;
 }
 
-int buffer_line(const char *line, void *baton) {
+static int buffer_line(const char *line, void *baton) {
 	response *r = baton;
 	if (r->buffer)
 		buffer_rewrite(&r->buffer, "%s\n%s", line);
@@ -234,7 +234,7 @@
 	return 0;
 }
 
-void *client_thread(void *baton)
+static void *client_thread(void *baton)
 {
 	struct thread_baton *b = baton;
 	request req;
@@ -266,7 +266,7 @@
 	return NULL;
 }
 
-int handle_connect(daemon_state s)
+static int handle_connect(daemon_state s)
 {
 	struct sockaddr_un sockaddr;
 	client_handle client;
@@ -345,7 +345,6 @@
 		s.daemon_init(&s);
 
 	while (!_shutdown_requested && !failed) {
-		int status;
 		fd_set in;
 		FD_ZERO(&in);
 		FD_SET(s.socket_fd, &in);
--- LVM2/daemons/common/daemon-shared.c	2011/07/18 14:42:44	1.4
+++ LVM2/daemons/common/daemon-shared.c	2011/08/31 12:18:40	1.5
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <malloc.h>
 #include <string.h>
+#include <unistd.h>
 #include <assert.h>
 #include "daemon-shared.h"
 
@@ -80,7 +81,7 @@
 	dm_asprintf(&buffer, "%s = \"%s\"\n", what, id);
 	if (!buffer) goto fail;
 
-	while (next = va_arg(ap, char *)) {
+	while ((next = va_arg(ap, char *))) {
 		old = buffer;
 		assert(strchr(next, '='));
 		keylen = strchr(next, '=') - next;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2/daemons/common daemon-client.c daemon-ser ...
@ 2011-09-17 14:49 zkabelac
  0 siblings, 0 replies; 3+ messages in thread
From: zkabelac @ 2011-09-17 14:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-09-17 14:49:18

Modified files:
	daemons/common : daemon-client.c daemon-server.c daemon-shared.c 

Log message:
	More gcc warnings removed

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6

--- LVM2/daemons/common/daemon-client.c	2011/08/31 12:18:40	1.7
+++ LVM2/daemons/common/daemon-client.c	2011/09/17 14:49:18	1.8
@@ -9,8 +9,9 @@
 #include <errno.h> // ENOMEM
 
 daemon_handle daemon_open(daemon_info i) {
-	daemon_handle h;
+	daemon_handle h = { .protocol = 0 };
 	struct sockaddr_un sockaddr;
+
 	if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM /* | SOCK_NONBLOCK */, 0)) < 0) {
 		perror("socket");
 		goto error;
@@ -23,7 +24,6 @@
 		perror("connect");
 		goto error;
 	}
-	h.protocol = 0;
 	return h;
 error:
 	if (h.socket_fd >= 0)
@@ -59,16 +59,19 @@
 
 daemon_reply daemon_send_simple(daemon_handle h, char *id, ...)
 {
+	static const daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL };
+	daemon_request rq;
+	daemon_reply repl;
 	va_list ap;
+
 	va_start(ap, id);
-	daemon_request rq = { .buffer = format_buffer("request", id, ap) };
+	rq.buffer = format_buffer("request", id, ap);
+	va_end(ap);
 
-	if (!rq.buffer) {
-		daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL };
+	if (!rq.buffer)
 		return err;
-	}
 
-	daemon_reply repl = daemon_send(h, rq);
+	repl = daemon_send(h, rq);
 	dm_free(rq.buffer);
 	return repl;
 }
--- LVM2/daemons/common/daemon-server.c	2011/08/31 12:39:58	1.13
+++ LVM2/daemons/common/daemon-server.c	2011/09/17 14:49:18	1.14
@@ -204,12 +204,15 @@
 response daemon_reply_simple(const char *id, ...)
 {
 	va_list ap;
+	response res = { .cft = NULL };
+
 	va_start(ap, id);
-	response res = { .buffer = format_buffer("response", id, ap), .cft = NULL };
 
-	if (!res.buffer)
+	if (!(res.buffer = format_buffer("response", id, ap)))
 		res.error = ENOMEM;
 
+	va_end(ap);
+
 	return res;
 }
 
@@ -238,6 +241,8 @@
 {
 	struct thread_baton *b = baton;
 	request req;
+	response res;
+
 	while (1) {
 		if (!read_buffer(b->client.socket_fd, &req.buffer))
 			goto fail;
@@ -245,7 +250,7 @@
 		req.cft = dm_config_from_string(req.buffer);
 		if (!req.cft)
 			fprintf(stderr, "error parsing request:\n %s\n", req.buffer);
-		response res = b->s.handler(b->s, b->client, req);
+		res = b->s.handler(b->s, b->client, req);
 		if (req.cft)
 			dm_config_destroy(req.cft);
 		dm_free(req.buffer);
@@ -268,25 +273,24 @@
 
 static int handle_connect(daemon_state s)
 {
+	struct thread_baton *baton;
 	struct sockaddr_un sockaddr;
-	client_handle client;
+	client_handle client = { .thread_id = 0 };
 	socklen_t sl = sizeof(sockaddr);
-	int client_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl);
-	if (client_fd < 0)
+
+	client.socket_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl);
+	if (client.socket_fd < 0)
 		return 0;
 
-	struct thread_baton *baton = malloc(sizeof(struct thread_baton));
-	if (!baton)
+	if (!(baton = malloc(sizeof(struct thread_baton))))
 		return 0;
 
-	client.socket_fd = client_fd;
-	client.read_buf = 0;
-	client.private = 0;
 	baton->s = s;
 	baton->client = client;
 
 	if (pthread_create(&baton->client.thread_id, NULL, client_thread, baton))
 		return 0;
+
 	return 1;
 }
 
--- LVM2/daemons/common/daemon-shared.c	2011/08/31 12:18:40	1.5
+++ LVM2/daemons/common/daemon-shared.c	2011/09/17 14:49:18	1.6
@@ -17,6 +17,8 @@
 int read_buffer(int fd, char **buffer) {
 	int bytes = 0;
 	int buffersize = 32;
+	char *new;
+	char *end;
 	*buffer = malloc(buffersize + 1);
 
 	while (1) {
@@ -30,14 +32,12 @@
 
 		if (bytes == buffersize) {
 			buffersize += 1024;
-			char *new = realloc(*buffer, buffersize + 1);
-			if (new)
-				*buffer = new;
-			else
+			if (!(new = realloc(*buffer, buffersize + 1)))
 				goto fail;
+
+			*buffer = new;
 		} else {
 			(*buffer)[bytes] = 0;
-			char *end;
 			if ((end = strstr((*buffer) + bytes - 2, "\n\n"))) {
 				*end = 0;
 				break; /* success, we have the full message now */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* LVM2/daemons/common daemon-client.c daemon-ser ...
@ 2011-06-29 22:20 mornfall
  0 siblings, 0 replies; 3+ messages in thread
From: mornfall @ 2011-06-29 22:20 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2011-06-29 22:20:14

Modified files:
	daemons/common : daemon-client.c daemon-server.c daemon-shared.c 
	                 daemon-shared.h 

Log message:
	Differentiate the request and response format, in daemon/common.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3

--- LVM2/daemons/common/daemon-client.c	2011/06/27 13:58:11	1.4
+++ LVM2/daemons/common/daemon-client.c	2011/06/29 22:20:14	1.5
@@ -60,7 +60,7 @@
 {
 	va_list ap;
 	va_start(ap, id);
-	daemon_request rq = { .buffer = format_buffer(id, ap) };
+	daemon_request rq = { .buffer = format_buffer("request", id, ap) };
 
 	if (!rq.buffer) {
 		daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL };
--- LVM2/daemons/common/daemon-server.c	2011/06/27 13:58:11	1.6
+++ LVM2/daemons/common/daemon-server.c	2011/06/29 22:20:14	1.7
@@ -205,7 +205,7 @@
 {
 	va_list ap;
 	va_start(ap, id);
-	response res = { .buffer = format_buffer(id, ap), .cft = NULL };
+	response res = { .buffer = format_buffer("response", id, ap), .cft = NULL };
 
 	if (!res.buffer)
 		res.error = ENOMEM;
--- LVM2/daemons/common/daemon-shared.c	2011/06/27 13:15:49	1.2
+++ LVM2/daemons/common/daemon-shared.c	2011/06/29 22:20:14	1.3
@@ -70,13 +70,13 @@
 	return 0;
 }
 
-char *format_buffer(char *id, va_list ap)
+char *format_buffer(const char *what, const char *id, va_list ap)
 {
 	char *buffer, *old;
 	char *next;
 	char *format;
 
-	dm_asprintf(&buffer, "request = \"%s\"\n", id);
+	dm_asprintf(&buffer, "%s = \"%s\"\n", what, id);
 	if (!buffer) goto fail;
 
 	while (next = va_arg(ap, char *)) {
--- LVM2/daemons/common/daemon-shared.h	2011/06/27 13:15:49	1.2
+++ LVM2/daemons/common/daemon-shared.h	2011/06/29 22:20:14	1.3
@@ -3,4 +3,4 @@
 
 int read_buffer(int fd, char **buffer);
 int write_buffer(int fd, char *buffer, int length);
-char *format_buffer(char *id, va_list ap);
+char *format_buffer(const char *what, const char *id, va_list ap);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-17 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 12:18 LVM2/daemons/common daemon-client.c daemon-ser mornfall
  -- strict thread matches above, loose matches on Subject: below --
2011-09-17 14:49 zkabelac
2011-06-29 22:20 mornfall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).