Re: [PATCH 2/5 v2] unpack_trees: group errors by type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Diane Gasselin <diane.gasselin@xxxxxxxxxxxxxxx> writes:

> In display_error_msgs(), I cannot access o->msg because I would not
> know which error I am treating.

You do:

static void display_error_msgs(struct unpack_trees_options *o)
{
...
	for (i = 0; i < NB_UNPACK_TREES_ERROR; i++) {
		...
	}

You know "i", so you know which error it is. The difficulty is that
the rejected paths are in an array, while the error messages are in a
struct, but you can either:

* Turn the struct into an array, and say msgs[would_overwrite] instead
  of msgs.would_overwrite (which would also simplify the code
  elsewhere since you would be able to write "ERRORMSG(o, error)" and
  such things).

* Do

switch (i) {
case would_overwrite:
	msg = o->msg.would_overwrite;
	break;
case not_uptodate_file:
	msg = o->msg.not_uptodate_file;
	break;
case not_uptodate_dir:
	msg = o->msg.not_uptodate_dir;
	break;
case would_lose_untracked_overwritten:
	msg = o->msg.would_lose_untracked_overwritten;
	break;
case would_lose_untracked_removed:
	msg = o->msg.would_lose_untracked_removed;
	break;
case sparse_not_uptodate_file:
	msg = o->msg.sparse_not_uptodate_file;
	break;
}

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]