You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							738 lines
						
					
					
						
							23 KiB
						
					
					
				
			
		
		
	
	
							738 lines
						
					
					
						
							23 KiB
						
					
					
				| # --- SDE-COPYRIGHT-NOTE-BEGIN --- | |
| # This copyright note is auto-generated by ./scripts/Create-CopyPatch. | |
| # | |
| # Filename: package/.../csync2/csync2-2.0-rc1-upstream-fixes-b7490b4.patch | |
| # Copyright (C) 2011 The OpenSDE Project | |
| # | |
| # More information can be found in the files COPYING and README. | |
| # | |
| # This patch file is dual-licensed. It is available under the license the | |
| # patched project is licensed under, as long as it is an OpenSource license | |
| # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms | |
| # of the GNU General Public License as published by the Free Software | |
| # Foundation; either version 2 of the License, or (at your option) any later | |
| # version. | |
| # --- SDE-COPYRIGHT-NOTE-END --- | |
|  | |
| From e5190e7660a7aff9f435c224b5852d825c1148fe Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 11:15:38 +0100 | |
| Subject: [PATCH 1/9] fix inetd protocol breakage | |
|  | |
| Don't csync_debug(0,...) to often, it breaks protocol on inetd, | |
| because with inetd, stderr and stdout point to the same socket. | |
|  | |
| Any "status" or "progress" or "debug" message printed to stderr | |
| ends up on the socket, and is interpreted as protocol error | |
| by the client. | |
|  | |
| So don't do that. | |
| --- | |
|  daemon.c |   18 +++++++++--------- | |
|  1 files changed, 9 insertions(+), 9 deletions(-) | |
|  | |
| diff --git a/daemon.c b/daemon.c | |
| index 57dfe49..4fadb73 100644 | |
| --- a/daemon.c | |
| +++ b/daemon.c | |
| @@ -119,11 +119,11 @@ int csync_file_backup(const char *filename) | |
|  	    int fd_in, fd_out, i; | |
|  	    int lastSlash; | |
|  	    mode_t mode; | |
| -	    csync_debug(0, "backup\n"); | |
| +	    csync_debug(1, "backup\n"); | |
|  	    // Skip generation of directories | |
|  	    rc =  stat(filename, &buf); | |
|  	    if (S_ISDIR(buf.st_mode)) { | |
| -	      csync_debug(0, "directory. Skip generation \n"); | |
| +	      csync_debug(1, "directory. Skip generation \n"); | |
|  	      return 0; | |
|  	    } | |
|   | |
| @@ -149,7 +149,7 @@ int csync_file_backup(const char *filename) | |
|   | |
|  		backup_filename[bak_dir_len+i] = 0; | |
|   | |
| -		csync_debug(0, "mkdir %s \n", backup_filename); | |
| +		csync_debug(1, "mkdir %s \n", backup_filename); | |
|   | |
|  		mkdir(backup_filename, mode); | |
|  		// Dont check the empty string. | |
| @@ -175,7 +175,7 @@ int csync_file_backup(const char *filename) | |
|  	      snprintf(backup_otherfilename+bak_dir_len+filename_len, 10, ".%d", i); | |
|   | |
|  	      rc = rename(backup_filename, backup_otherfilename); | |
| -	      csync_debug(0, "renaming backup files '%s' to '%s'. rc = %d\n", backup_filename, backup_otherfilename, rc); | |
| +	      csync_debug(1, "renaming backup files '%s' to '%s'. rc = %d\n", backup_filename, backup_otherfilename, rc); | |
|  	       | |
|  	    } | |
|   | |
| @@ -192,11 +192,11 @@ int csync_file_backup(const char *filename) | |
|  	      return 1; | |
|  	    } | |
|   | |
| -	    csync_debug(0,"Copying data from %s to backup file %s \n", filename, backup_filename); | |
| +	    csync_debug(1,"Copying data from %s to backup file %s \n", filename, backup_filename); | |
|   | |
| -	    int rc  = csync_copy_file(fd_in, fd_out); | |
| +	    rc  = csync_copy_file(fd_in, fd_out); | |
|  	    if (rc != 0) { | |
| -		csync_debug(0, "csync_backup error 2\n"); | |
| +		csync_debug(1, "csync_backup error 2\n"); | |
|   | |
|  		snprintf(error_buffer, 1024, | |
|  			 "Write error while backing up '%s': %s\n", | |
| @@ -208,10 +208,10 @@ int csync_file_backup(const char *filename) | |
|  		// return 1; | |
|  	    } | |
|  	    csync_setBackupFileStatus(backup_filename, bak_dir_len); | |
| -	    csync_debug(0, "csync_backup loop end\n"); | |
| +	    csync_debug(1, "csync_backup loop end\n"); | |
|  	  } | |
|  	} | |
| -	csync_debug(0, "csync_backup end\n"); | |
| +	csync_debug(1, "csync_backup end\n"); | |
|  	return 0; | |
|  } | |
|   | |
| --  | |
| 1.7.2.3 | |
|  | |
| From 2d459f6cab22b9c4f682b02b6b21e12cf27c23df Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 11:43:02 +0100 | |
| Subject: [PATCH 2/9] fix recursive check for deleted files | |
|  | |
| Fix breakage by 448e725a61cdb869b825cacce08f0974e2a4a408: | |
| just dropping "or 1" (for "give me all you have") | |
| because of "ERROR:  argument of OR must be type boolean, not type integer" | |
| is wrong: it results in "give me just the exact match" ;-( | |
|  | |
| Correct fix: "OR TRUE". | |
| --- | |
|  check.c |    2 +- | |
|  1 files changed, 1 insertions(+), 1 deletions(-) | |
|  | |
| diff --git a/check.c b/check.c | |
| index fc3a05b..6d64c3a 100644 | |
| --- a/check.c | |
| +++ b/check.c | |
| @@ -215,7 +215,7 @@ void csync_check_del(const char *file, int recursive, int init_run) | |
|   | |
|  	if ( recursive ) { | |
|  		if ( !strcmp(file, "/") ) | |
| -		  ASPRINTF(&where_rec, "") | |
| +		  ASPRINTF(&where_rec, "OR TRUE") | |
|  		else | |
|  		  ASPRINTF(&where_rec, "UNION ALL SELECT filename from file where filename > '%s/' " | |
|  				"and filename < '%s0'", | |
| --  | |
| 1.7.2.3 | |
|  | |
| From aec0438822f65d902b79446196112e0a7dae9efe Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 12:50:02 +0000 | |
| Subject: [PATCH 3/9] fix compiler warnings about statement without effect (ASPRINTF macro) | |
|  | |
| ASPRINTF and VASPRINTF macros are used | |
| used everywhere as "void", so make it void. | |
|  | |
| do { ... } while (0) makes it accept a ; at the end, | |
| which is better practice, I think. | |
| --- | |
|  check.c       |    4 ++-- | |
|  csync2.c      |   12 ++++++------ | |
|  csync2.h      |   20 +++++++++----------- | |
|  db.c          |   20 ++++++++++---------- | |
|  db_mysql.c    |    2 +- | |
|  db_postgres.c |    6 +++--- | |
|  getrealfn.c   |    4 ++-- | |
|  prefixsubst.c |    4 ++-- | |
|  8 files changed, 35 insertions(+), 37 deletions(-) | |
|  | |
| diff --git a/check.c b/check.c | |
| index 6d64c3a..1de56f8 100644 | |
| --- a/check.c | |
| +++ b/check.c | |
| @@ -215,11 +215,11 @@ void csync_check_del(const char *file, int recursive, int init_run) | |
|   | |
|  	if ( recursive ) { | |
|  		if ( !strcmp(file, "/") ) | |
| -		  ASPRINTF(&where_rec, "OR TRUE") | |
| +		  ASPRINTF(&where_rec, "OR TRUE"); | |
|  		else | |
|  		  ASPRINTF(&where_rec, "UNION ALL SELECT filename from file where filename > '%s/' " | |
|  				"and filename < '%s0'", | |
| -				url_encode(file), url_encode(file)) | |
| +				url_encode(file), url_encode(file)); | |
|  	} | |
|   | |
|  	SQL_BEGIN("Checking for removed files", | |
| diff --git a/csync2.c b/csync2.c | |
| index e683c61..d079c85 100644 | |
| --- a/csync2.c | |
| +++ b/csync2.c | |
| @@ -588,7 +588,7 @@ int main(int argc, char ** argv) | |
|  			cfgname = strdup(url_decode(para)); | |
|  	} | |
|  	if ( !*cfgname ) { | |
| -	     ASPRINTF(&file_config, ETCDIR "/csync2.cfg") | |
| +	     ASPRINTF(&file_config, ETCDIR "/csync2.cfg"); | |
|  	} else { | |
|  		int i; | |
|   | |
| @@ -600,7 +600,7 @@ int main(int argc, char ** argv) | |
|  				return mode != MODE_INETD; | |
|  			} | |
|   | |
| -		ASPRINTF(&file_config, ETCDIR "/csync2_%s.cfg", cfgname) | |
| +		ASPRINTF(&file_config, ETCDIR "/csync2_%s.cfg", cfgname); | |
|  	} | |
|   | |
|  	csync_debug(2, "Config-File:   %s\n", file_config); | |
| @@ -735,11 +735,11 @@ found_a_group:; | |
|  					char *where_rec = ""; | |
|   | |
|  					if ( !strcmp(realname, "/") ) | |
| -						ASPRINTF(&where_rec, "or 1") | |
| +						ASPRINTF(&where_rec, "or 1"); | |
|  					else | |
|  						ASPRINTF(&where_rec, "UNION ALL SELECT filename from file where filename > '%s/' " | |
|  							"and filename < '%s0'", | |
| -							url_encode(pfname), url_encode(pfname)) | |
| +							url_encode(pfname), url_encode(pfname)); | |
|   | |
|  					SQL_BEGIN("Adding dirty entries recursively", | |
|  						"SELECT filename FROM file WHERE filename = '%s' %s", | |
| @@ -761,11 +761,11 @@ found_a_group:; | |
|   | |
|  				if ( recursive ) { | |
|  					if ( !strcmp(realname, "/") ) | |
| -						ASPRINTF(&where_rec, "or 1") | |
| +						ASPRINTF(&where_rec, "or 1"); | |
|  					else | |
|  						ASPRINTF(&where_rec, "or (filename > '%s/' " | |
|  							"and filename < '%s0')", | |
| -							url_encode(realname), url_encode(realname)) | |
| +							url_encode(realname), url_encode(realname)); | |
|  				} | |
|   | |
|  				SQL("Mark file as to be forced", | |
| diff --git a/csync2.h b/csync2.h | |
| index 57431c1..1310582 100644 | |
| --- a/csync2.h | |
| +++ b/csync2.h | |
| @@ -37,22 +37,20 @@ | |
|   | |
|  #define DB_SCHEMA_VERSION 0 | |
|   | |
| -/* asprintf with test for no memory. Use these macros without trailing ';' */ | |
| +/* asprintf with test for no memory */ | |
|   | |
| -#define ASPRINTF(s, fmt, ...) {\ | |
| -	int __ret;\ | |
| -	if ((__ret = asprintf(s, fmt, ##__VA_ARGS__)) < 0) \ | |
| +#define ASPRINTF(s, fmt, ...) do {\ | |
| +	int __ret = asprintf(s, fmt, ##__VA_ARGS__);\ | |
| +	if (__ret < 0) \ | |
|  		csync_fatal("Out of memory in asprintf at %s:%d\n", __FILE__, __LINE__);\ | |
| -	__ret;\ | |
| -} | |
| +} while (0) | |
|   | |
|   | |
| -#define VASPRINTF(s, fmt, args) {\ | |
| -	int __ret;\ | |
| -	if ((__ret = vasprintf(s, fmt, args)) < 0) \ | |
| +#define VASPRINTF(s, fmt, args) do {\ | |
| +	int __ret = vasprintf(s, fmt, args);\ | |
| +	if (__ret < 0) \ | |
|  		csync_fatal("Out of memory in vasprintf at %s:%d\n", __FILE__, __LINE__);\ | |
| -	__ret;\ | |
| -} | |
| +} while (0) | |
|   | |
|   | |
|  /* action.c */ | |
| diff --git a/db.c b/db.c | |
| index d6a58c6..68848b3 100644 | |
| --- a/db.c | |
| +++ b/db.c | |
| @@ -172,7 +172,7 @@ void csync_db_sql(const char *err, const char *fmt, ...) | |
|  	int rc, busyc = 0; | |
|   | |
|  	va_start(ap, fmt); | |
| -	VASPRINTF(&sql, fmt, ap) | |
| +	VASPRINTF(&sql, fmt, ap); | |
|  	va_end(ap); | |
|   | |
|  	in_sql_query++; | |
| @@ -204,7 +204,7 @@ void* csync_db_begin(const char *err, const char *fmt, ...) | |
|  	int rc, busyc = 0; | |
|  	char *ppTail;  | |
|  	va_start(ap, fmt); | |
| -	VASPRINTF(&sql, fmt, ap) | |
| +	VASPRINTF(&sql, fmt, ap); | |
|  	va_end(ap); | |
|   | |
|  	in_sql_query++; | |
| @@ -309,25 +309,25 @@ char *db_default_database(char *dbdir, char *myhostname, char *cfg_name) | |
|   | |
|  #if defined(HAVE_SQLITE3) | |
|  	if (cfg_name[0] != '\0') | |
| -		ASPRINTF(&db, "sqlite3://%s/%s_%s" DBEXTENSION, dbdir, myhostname, cfgname) | |
| +		ASPRINTF(&db, "sqlite3://%s/%s_%s" DBEXTENSION, dbdir, myhostname, cfgname); | |
|  	else | |
| -		ASPRINTF(&db, "sqlite3://%s/%s" DBEXTENSION, dbdir, myhostname) | |
| +		ASPRINTF(&db, "sqlite3://%s/%s" DBEXTENSION, dbdir, myhostname); | |
|  #elif defined(HAVE_SQLITE) | |
|  	if (cfg_name[0] != '\0') | |
| -		ASPRINTF(&db, "sqlite2://%s/%s_%s" DBEXTENSION, dbdir, myhostname, cfgname) | |
| +		ASPRINTF(&db, "sqlite2://%s/%s_%s" DBEXTENSION, dbdir, myhostname, cfgname); | |
|  	else | |
| -		ASPRINTF(&db, "sqlite2://%s/%s" DBEXTENSION, dbdir, myhostname) | |
| +		ASPRINTF(&db, "sqlite2://%s/%s" DBEXTENSION, dbdir, myhostname); | |
|  #elif defined(HAVE_MYSQL) | |
|  	if (cfg_name[0] != '\0') | |
| -		ASPRINTF(&db, "mysql://root@localhost/csync2_%s_%s" DBEXTENSION, myhostname, cfgname) | |
| +		ASPRINTF(&db, "mysql://root@localhost/csync2_%s_%s" DBEXTENSION, myhostname, cfgname); | |
|  	else | |
| -		ASPRINTF(&db, "mysql://root@localhost/csync2_%s" DBEXTENSION, myhostname) | |
| +		ASPRINTF(&db, "mysql://root@localhost/csync2_%s" DBEXTENSION, myhostname); | |
|   | |
|  #elif defined(HAVE_POSTGRES) | |
|  	if (cfg_name[0] != '\0') | |
| -		ASPRINTF(&db, "pgsql://root@localhost/csync2_%s_%s" DBEXTENSION, myhostname, cfgname) | |
| +		ASPRINTF(&db, "pgsql://root@localhost/csync2_%s_%s" DBEXTENSION, myhostname, cfgname); | |
|  	else | |
| -		ASPRINTF(&db, "pgsql://root@localhost/csync2_%s" DBEXTENSION, myhostname) | |
| +		ASPRINTF(&db, "pgsql://root@localhost/csync2_%s" DBEXTENSION, myhostname); | |
|   | |
|  #else | |
|  #error "No database backend available. Please install either libpg, libmysqlclient or libsqlite, reconfigure and recompile" | |
| diff --git a/db_mysql.c b/db_mysql.c | |
| index c15a219..1b6d09e 100644 | |
| --- a/db_mysql.c | |
| +++ b/db_mysql.c | |
| @@ -140,7 +140,7 @@ int db_mysql_open(const char *file, db_conn_p *conn_p) | |
|    if (f.mysql_real_connect_fn(db, host, user, pass, database, port, unix_socket, 0) == NULL) { | |
|      if (f.mysql_errno_fn(db) == ER_BAD_DB_ERROR) { | |
|        if (f.mysql_real_connect_fn(db, host, user, pass, NULL, port, unix_socket, 0) != NULL) { | |
| -	ASPRINTF(&create_database_statement, "create database %s", database) | |
| +	ASPRINTF(&create_database_statement, "create database %s", database); | |
|   | |
|  	csync_debug(2, "creating database %s\n", database); | |
|          if (f.mysql_query_fn(db, create_database_statement) != 0) | |
| diff --git a/db_postgres.c b/db_postgres.c | |
| index 13a7a41..b40bdfb 100644 | |
| --- a/db_postgres.c | |
| +++ b/db_postgres.c | |
| @@ -140,7 +140,7 @@ int db_postgres_open(const char *file, db_conn_p *conn_p) | |
|      return rc; | |
|   | |
|    ASPRINTF(&pg_conn_info, "host='%s' user='%s' password='%s' dbname='%s' port=%d", | |
| -	host, user, pass, database, port) | |
| +	host, user, pass, database, port); | |
|   | |
|    pg_conn = f.PQconnectdb_fn(pg_conn_info); | |
|    if (pg_conn == NULL) | |
| @@ -151,7 +151,7 @@ int db_postgres_open(const char *file, db_conn_p *conn_p) | |
|      free(pg_conn_info); | |
|   | |
|      ASPRINTF(&pg_conn_info, "host='%s' user='%s' password='%s' dbname='postgres' port=%d", | |
| -	  host, user, pass, port) | |
| +	  host, user, pass, port); | |
|   | |
|      pg_conn = f.PQconnectdb_fn(pg_conn_info); | |
|      if (pg_conn == NULL) | |
| @@ -186,7 +186,7 @@ int db_postgres_open(const char *file, db_conn_p *conn_p) | |
|        free(pg_conn_info); | |
|   | |
|        ASPRINTF(&pg_conn_info, "host='%s' user='%s' password='%s' dbname='%s' port=%d", | |
| -	    host, user, pass, database, port) | |
| +	    host, user, pass, database, port); | |
|   | |
|        pg_conn = f.PQconnectdb_fn(pg_conn_info); | |
|        if (pg_conn == NULL) | |
| diff --git a/getrealfn.c b/getrealfn.c | |
| index 1f6840c..b2bc0b7 100644 | |
| --- a/getrealfn.c | |
| +++ b/getrealfn.c | |
| @@ -54,7 +54,7 @@ char *getrealfn(const char *filename) | |
|  	if ( *tempfn != '/' ) { | |
|  		char *t2, *t1 = my_get_current_dir_name(); | |
|   | |
| -		ASPRINTF(&t2, "%s/%s", t1, tempfn) | |
| +		ASPRINTF(&t2, "%s/%s", t1, tempfn); | |
|  		free(t1); | |
|  		free(tempfn); | |
|  		tempfn = t2; | |
| @@ -111,7 +111,7 @@ char *getrealfn(const char *filename) | |
|  		if ( !chdir(tempfn) ) { | |
|  			char *t2, *t1 = my_get_current_dir_name(); | |
|  			if ( st_mark ) { | |
| -				ASPRINTF(&t2, "%s/%s", t1, st_mark+1) | |
| +				ASPRINTF(&t2, "%s/%s", t1, st_mark+1); | |
|  				free(tempfn); free(t1); tempfn = t2; | |
|  			} else { | |
|  				free(tempfn); tempfn = t1; | |
| diff --git a/prefixsubst.c b/prefixsubst.c | |
| index 9fc1067..d003bb5 100644 | |
| --- a/prefixsubst.c | |
| +++ b/prefixsubst.c | |
| @@ -46,7 +46,7 @@ const char *prefixsubst(const char *in) | |
|  			ringbuff_counter = (ringbuff_counter+1) % RINGBUFF_LEN; | |
|  			if (ringbuff[ringbuff_counter]) | |
|  				free(ringbuff[ringbuff_counter]); | |
| -			ASPRINTF(&ringbuff[ringbuff_counter], "%s%s", p->path, path) | |
| +			ASPRINTF(&ringbuff[ringbuff_counter], "%s%s", p->path, path); | |
|  			return ringbuff[ringbuff_counter]; | |
|  		} | |
|  	} | |
| @@ -79,7 +79,7 @@ const char *prefixencode(const char *filename) { | |
|  					ringbuff_counter = (ringbuff_counter+1) % RINGBUFF_LEN; | |
|  					if (ringbuff[ringbuff_counter]) | |
|  						free(ringbuff[ringbuff_counter]); | |
| -					ASPRINTF(&ringbuff[ringbuff_counter], "%%%s%%%s", p->name, filename+p_len) | |
| +					ASPRINTF(&ringbuff[ringbuff_counter], "%%%s%%%s", p->name, filename+p_len); | |
|  					return ringbuff[ringbuff_counter]; | |
|  				} | |
|  			} | |
| --  | |
| 1.7.2.3 | |
|  | |
| From 2cb983a1ccf36b0d5b6d117e8e1e8770d8e3e013 Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:14:11 +0000 | |
| Subject: [PATCH 4/9] suppress compiler warning about unused yyinput/yyunput | |
|  | |
| --- | |
|  cfgfile_scanner.l |    4 ++++ | |
|  1 files changed, 4 insertions(+), 0 deletions(-) | |
|  | |
| diff --git a/cfgfile_scanner.l b/cfgfile_scanner.l | |
| index 345a45b..5e93f7c 100644 | |
| --- a/cfgfile_scanner.l | |
| +++ b/cfgfile_scanner.l | |
| @@ -25,9 +25,13 @@ | |
|  #define MAX_INCLUDE_DEPTH 10 | |
|  YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; | |
|  int include_stack_ptr = 0; | |
| + | |
| +#define YY_NO_INPUT 1 | |
| +#define YY_NO_UNPUT 1 | |
|  %} | |
|   | |
|  %option noyywrap yylineno | |
| +%option nounput | |
|  %x STRING INCL | |
|   | |
|  %% | |
| --  | |
| 1.7.2.3 | |
|  | |
| From d9b8e2fbfc8cf99e3a9a920e06a4e349c9ebebeb Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:20:29 +0000 | |
| Subject: [PATCH 5/9] fix compiler warnings about unused or uninitialized variables | |
|  | |
| --- | |
|  conn.c   |    2 +- | |
|  daemon.c |    3 +-- | |
|  rsync.c  |    2 -- | |
|  update.c |    1 - | |
|  4 files changed, 2 insertions(+), 6 deletions(-) | |
|  | |
| diff --git a/conn.c b/conn.c | |
| index 113d5d9..3f06005 100644 | |
| --- a/conn.c | |
| +++ b/conn.c | |
| @@ -52,7 +52,7 @@ int conn_connect(const char *peername) | |
|  { | |
|  	struct addrinfo hints; | |
|  	struct addrinfo *result, *rp; | |
| -	int sfd, s, on = 1; | |
| +	int sfd, s; | |
|   | |
|  	/* Obtain address(es) matching host/port */ | |
|  	memset(&hints, 0, sizeof(struct addrinfo)); | |
| diff --git a/daemon.c b/daemon.c | |
| index 4fadb73..98a5b47 100644 | |
| --- a/daemon.c | |
| +++ b/daemon.c | |
| @@ -117,7 +117,7 @@ int csync_file_backup(const char *filename) | |
|  	    char backup_filename[bak_dir_len + filename_len + 10]; | |
|  	    char backup_otherfilename[bak_dir_len + filename_len + 10]; | |
|  	    int fd_in, fd_out, i; | |
| -	    int lastSlash; | |
| +	    int lastSlash = 0; | |
|  	    mode_t mode; | |
|  	    csync_debug(1, "backup\n"); | |
|  	    // Skip generation of directories | |
| @@ -343,7 +343,6 @@ int verify_peername(const char *name, address_t *peeraddr) | |
|  	sa_family_t af = peeraddr->sa.sa_family; | |
|  	struct addrinfo hints; | |
|  	struct addrinfo *result, *rp; | |
| -	size_t len; | |
|  	int try_mapped_ipv4; | |
|  	int s; | |
|   | |
| diff --git a/rsync.c b/rsync.c | |
| index eed2d85..86482ee 100644 | |
| --- a/rsync.c | |
| +++ b/rsync.c | |
| @@ -506,9 +506,7 @@ int csync_rs_patch(const char *filename) | |
|  	int backup_errno; | |
|  	rs_stats_t stats; | |
|  	rs_result result; | |
| -	char buffer[512]; | |
|  	char *errstr = "?"; | |
| -	int rc; | |
|  	char tmpfname[MAXPATHLEN], newfname[MAXPATHLEN]; | |
|   | |
|  	csync_debug(3, "Csync2 / Librsync: csync_rs_patch('%s')\n", filename); | |
| diff --git a/update.c b/update.c | |
| index f747dd9..b2c2b85 100644 | |
| --- a/update.c | |
| +++ b/update.c | |
| @@ -544,7 +544,6 @@ void csync_update_host(const char *peername, | |
|  	struct textlist *tl_mod = 0, **last_tn=&tl; | |
|  	char *current_name = 0; | |
|  	struct stat st; | |
| -	char *myname ;  | |
|  	SQL_BEGIN("Get files for host from dirty table", | |
|  		"SELECT filename, myname, forced FROM dirty WHERE peername = '%s' " | |
|  		"ORDER by filename ASC", url_encode(peername)) | |
| --  | |
| 1.7.2.3 | |
|  | |
| From ec538733e9ccf2688b16592ce9579fa4e859f4fc Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:22:22 +0000 | |
| Subject: [PATCH 6/9] fix compiler warnings about signedness or other type mismatch | |
|  | |
| --- | |
|  conn.c      |    6 +++--- | |
|  csync2.c    |    4 ++-- | |
|  csync2.h    |    2 +- | |
|  db_sqlite.c |    4 ++-- | |
|  4 files changed, 8 insertions(+), 8 deletions(-) | |
|  | |
| diff --git a/conn.c b/conn.c | |
| index 3f06005..8dda10d 100644 | |
| --- a/conn.c | |
| +++ b/conn.c | |
| @@ -395,7 +395,7 @@ int conn_raw_read(void *buf, size_t count) | |
|  	return 0; | |
|  } | |
|   | |
| -void conn_debug(const char *name, const unsigned char*buf, size_t count) | |
| +void conn_debug(const char *name, const char*buf, size_t count) | |
|  { | |
|  	int i; | |
|   | |
| @@ -458,9 +458,9 @@ void conn_printf(const char *fmt, ...) | |
|  	conn_write(buffer, size); | |
|  } | |
|   | |
| -int conn_gets(char *s, int size) | |
| +size_t conn_gets(char *s, size_t size) | |
|  { | |
| -	int i=0; | |
| +	size_t i=0; | |
|   | |
|  	while (i<size-1) { | |
|  		int rc = conn_raw_read(s+i, 1); | |
| diff --git a/csync2.c b/csync2.c | |
| index d079c85..3b1cb6a 100644 | |
| --- a/csync2.c | |
| +++ b/csync2.c | |
| @@ -310,7 +310,7 @@ static int csync_server_loop(int single_connect) | |
|  	printf("Csync2 daemon running. Waiting for connections.\n"); | |
|   | |
|  	while (1) { | |
| -		int addrlen = sizeof(addr); | |
| +		unsigned addrlen = sizeof(addr); | |
|  		int conn = accept(listenfd, &addr.sa, &addrlen); | |
|  		if (conn < 0) goto error; | |
|   | |
| @@ -782,7 +782,7 @@ found_a_group:; | |
|  			SQL_BEGIN("DB Dump - Hint", | |
|  				"SELECT recursive, filename FROM hint ORDER BY filename") | |
|  			{ | |
| -				printf("%s\t%s\n", SQL_V(0), url_decode(SQL_V(1))); | |
| +				printf("%s\t%s\n", (char*)SQL_V(0), url_decode(SQL_V(1))); | |
|  				retval = -1; | |
|  			} SQL_END; | |
|  			break; | |
| diff --git a/csync2.h b/csync2.h | |
| index 1310582..6032240 100644 | |
| --- a/csync2.h | |
| +++ b/csync2.h | |
| @@ -100,7 +100,7 @@ extern int conn_write(const void *buf, size_t count); | |
|   | |
|  extern void conn_printf(const char *fmt, ...); | |
|  extern int conn_fgets(char *s, int size); | |
| -extern int conn_gets(char *s, int size); | |
| +extern size_t conn_gets(char *s, size_t size); | |
|   | |
|   | |
|  /* db.c */ | |
| diff --git a/db_sqlite.c b/db_sqlite.c | |
| index 8018a01..81c5c75 100644 | |
| --- a/db_sqlite.c | |
| +++ b/db_sqlite.c | |
| @@ -180,9 +180,9 @@ const char *db_sqlite_stmt_get_column_text(db_stmt_p stmt, int column) { | |
|      return 0; | |
|    } | |
|    sqlite3_stmt *sqlite_stmt = stmt->private; | |
| -  const char *result  = f.sqlite3_column_text_fn(sqlite_stmt, column); | |
| +  const unsigned char *result  = f.sqlite3_column_text_fn(sqlite_stmt, column); | |
|    /* error handling */ | |
| -  return result;  | |
| +  return (const char*)result;  | |
|  } | |
|   | |
|  #if defined(HAVE_SQLITE3) | |
| --  | |
| 1.7.2.3 | |
|  | |
| From 763561c6313e02c2ac90a8f043e84d25547f7c21 Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:23:06 +0000 | |
| Subject: [PATCH 7/9] fix compiler warnings about implicit function declarations | |
|  | |
| --- | |
|  csync2.h     |    4 ++-- | |
|  db_api.c     |    5 +++++ | |
|  db_api.h     |    5 +++++ | |
|  db_sqlite2.h |    4 ++-- | |
|  4 files changed, 14 insertions(+), 4 deletions(-) | |
|  | |
| diff --git a/csync2.h b/csync2.h | |
| index 6032240..5240d15 100644 | |
| --- a/csync2.h | |
| +++ b/csync2.h | |
| @@ -113,9 +113,8 @@ extern void* csync_db_begin(const char *err, const char *fmt, ...); | |
|  extern int csync_db_next(void *vmx, const char *err, | |
|  		int *pN, const char ***pazValue, const char ***pazColName); | |
|  extern void csync_db_fin(void *vmx, const char *err); | |
| -#if defined(HAVE_LIBSQLITE3) | |
|  extern const void * csync_db_colblob(void *stmtx,int col); | |
| -#endif | |
| +extern char *db_default_database(char *dbdir, char *myhostname, char *cfg_name); | |
|   | |
|   | |
|  #define SQL(e, s, ...) csync_db_sql(e, s, ##__VA_ARGS__) | |
| @@ -203,6 +202,7 @@ extern void csync_remove_old(); | |
|  /* daemon.c */ | |
|   | |
|  extern void csync_daemon_session(); | |
| +extern int csync_copy_file(int fd_in, int fd_out); | |
|   | |
|   | |
|  /* getrealfn.c */ | |
| diff --git a/db_api.c b/db_api.c | |
| index f35abee..af5591c 100644 | |
| --- a/db_api.c | |
| +++ b/db_api.c | |
| @@ -12,6 +12,11 @@ | |
|  #include <time.h> | |
|  #include "db_api.h" | |
|   | |
| +#include "db_mysql.h" | |
| +#include "db_postgres.h" | |
| +#include "db_sqlite.h" | |
| +#include "db_sqlite2.h" | |
| + | |
|  #define DEADLOCK_MESSAGE \ | |
|  	"Database backend is exceedingly busy => Terminating (requesting retry).\n" | |
|   | |
| diff --git a/db_api.h b/db_api.h | |
| index ed5d6d1..eab627b 100644 | |
| --- a/db_api.h | |
| +++ b/db_api.h | |
| @@ -54,4 +54,9 @@ int       db_stmt_get_column_int(db_stmt_p  stmt, int column); | |
|  int       db_stmt_next (db_stmt_p stmt); | |
|  int       db_stmt_close(db_stmt_p stmt); | |
|   | |
| +void db_set_logger(db_conn_p conn, void (*logger)(int lv, const char *fmt, ...)); | |
| +int db_schema_version(db_conn_p db); | |
| +int db_upgrade_to_schema(db_conn_p db, int version); | |
| +const char *db_errmsg(db_conn_p conn); | |
| + | |
|  #endif | |
| diff --git a/db_sqlite2.h b/db_sqlite2.h | |
| index 24b2c32..79336a4 100644 | |
| --- a/db_sqlite2.h | |
| +++ b/db_sqlite2.h | |
| @@ -1,6 +1,6 @@ | |
|   | |
| -#ifndef DB_SQLITE_H | |
| -#define DB_SQLITE_H | |
| +#ifndef DB_SQLITE2_H | |
| +#define DB_SQLITE2_H | |
|   | |
|  /* public */ | |
|  int   db_sqlite2_open(const char *file, db_conn_p *conn_p); | |
| --  | |
| 1.7.2.3 | |
|  | |
| From 6d534181223d3fa06f2875373c5884c3c7ed5556 Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:23:44 +0000 | |
| Subject: [PATCH 8/9] fix compiler warning about assignment discards qualifier from pointer target type | |
|  | |
| --- | |
|  daemon.c |    6 ++---- | |
|  1 files changed, 2 insertions(+), 4 deletions(-) | |
|  | |
| diff --git a/daemon.c b/daemon.c | |
| index 98a5b47..0e35ff9 100644 | |
| --- a/daemon.c | |
| +++ b/daemon.c | |
| @@ -321,13 +321,11 @@ typedef union address { | |
|  const char *csync_inet_ntop(address_t *addr) | |
|  { | |
|  	char buf[INET6_ADDRSTRLEN]; | |
| -	char *pretty_print = NULL; | |
|  	sa_family_t af = addr->sa.sa_family; | |
| -	pretty_print = inet_ntop(af, | |
| +	return inet_ntop(af, | |
|  		af == AF_INET  ? (void*)&addr->sa_in.sin_addr : | |
|  		af == AF_INET6 ? (void*)&addr->sa_in6.sin6_addr : NULL, | |
| -		&buf, sizeof(buf)); | |
| -	return pretty_print; | |
| +		buf, sizeof(buf)); | |
|  } | |
|   | |
|  /* | |
| --  | |
| 1.7.2.3 | |
|  | |
| From b7490b4d2f9069e4e364c9f4824956ade4bad691 Mon Sep 17 00:00:00 2001 | |
| From: Lars Ellenberg <[email protected]> | |
| Date: Wed, 9 Feb 2011 13:24:51 +0000 | |
| Subject: [PATCH 9/9] fix compiler warning about empty snprintf format | |
|  | |
| --- | |
|  daemon.c |    3 +-- | |
|  1 files changed, 1 insertions(+), 2 deletions(-) | |
|  | |
| diff --git a/daemon.c b/daemon.c | |
| index 0e35ff9..2c054ed 100644 | |
| --- a/daemon.c | |
| +++ b/daemon.c | |
| @@ -170,8 +170,7 @@ int csync_file_backup(const char *filename) | |
|   | |
|  	      if (i != 1) | |
|  		snprintf(backup_filename+bak_dir_len+filename_len, 10, ".%d", i-1); | |
| -	      else | |
| -		snprintf(backup_filename+bak_dir_len+filename_len, 10, ""); | |
| +	      backup_filename[bak_dir_len+filename_len] = '\0'; | |
|  	      snprintf(backup_otherfilename+bak_dir_len+filename_len, 10, ".%d", i); | |
|   | |
|  	      rc = rename(backup_filename, backup_otherfilename); | |
| --  | |
| 1.7.2.3 | |
| 
 | |
| 
 |