commit d7e3ae4b74ef30e5a3ea255099a89b07697fb7cc
parent 09f08e4974aab8b8913de0125e81978ad9bf84c4
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Tue, 11 Jan 2022 16:16:25 +0100
report location of overlapping operations
Diffstat:
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/config.c b/src/config.c
@@ -286,9 +286,23 @@ getcline( conffile_t *cfile )
return 0;
}
+static const char *
+channel_str( const char *chan_name )
+{
+ if (!chan_name)
+ return "on the command line";
+
+ if (!*chan_name)
+ return "in global config section";
+
+ static char buf[100];
+ nfsnprintf( buf, sizeof(buf), "in Channel '%s'", chan_name );
+ return buf;
+}
+
/* XXX - this does not detect None conflicts ... */
int
-merge_ops( int cops, int ops[] )
+merge_ops( int cops, int ops[], const char *chan_name )
{
int aops, op;
uint i;
@@ -298,7 +312,7 @@ merge_ops( int cops, int ops[] )
if (aops & OP_MASK_TYPE) { // PullNew, etc.
if (aops & cops & OP_MASK_TYPE) { // Overlapping New, etc.
cfl:
- error( "Conflicting Sync args specified.\n" );
+ error( "Conflicting Sync args specified %s.\n", channel_str( chan_name ) );
return 1;
}
// Mix in non-overlapping Push/Pull or New, etc.
@@ -330,7 +344,7 @@ merge_ops( int cops, int ops[] )
op = boxOps[i].op;
if (ops[F] & (op * (XOP_HAVE_EXPUNGE / OP_EXPUNGE))) {
if (aops & cops & op) {
- error( "Conflicting %s args specified.\n", boxOps[i].name );
+ error( "Conflicting %s args specified %s.\n", boxOps[i].name, channel_str( chan_name ) );
return 1;
}
ops[F] |= cops & op;
@@ -485,7 +499,7 @@ load_config( const char *where )
} else if (!channel->stores[N]) {
error( "channel '%s' refers to no near side store\n", channel->name );
cfile.err = 1;
- } else if (merge_ops( cops, channel->ops )) {
+ } else if (merge_ops( cops, channel->ops, channel->name )) {
cfile.err = 1;
} else {
if (max_size != UINT_MAX) {
@@ -567,7 +581,7 @@ load_config( const char *where )
fclose (cfile.fp);
if (cfile.ms_warn)
warn( "Notice: Master/Slave are deprecated; use Far/Near instead.\n" );
- cfile.err |= merge_ops( gcops, global_conf.ops );
+ cfile.err |= merge_ops( gcops, global_conf.ops, "" );
if (!global_conf.sync_state) {
const char *state_home = getenv( "XDG_STATE_HOME" );
if (state_home)
diff --git a/src/config.h b/src/config.h
@@ -35,7 +35,7 @@ char parse_bool( conffile_t *cfile );
int parse_int( conffile_t *cfile );
uint parse_size( conffile_t *cfile );
int getcline( conffile_t *cfile );
-int merge_ops( int cops, int ops[] );
+int merge_ops( int cops, int ops[], const char *chan_name );
int load_config( const char *filename );
#endif
diff --git a/src/main.c b/src/main.c
@@ -468,7 +468,7 @@ main( int argc, char **argv )
}
#endif
- if (merge_ops( cops, mvars->ops ))
+ if (merge_ops( cops, mvars->ops, NULL ))
return 1;
if (load_config( config ))