Le 15 juin 2010 15:28, Matthieu Moy <Matthieu.Moy@xxxxxxxxxxxxxxx> a écrit : > 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/ > Thanks for your answers. I did the switch case at first but thought it was maybe a bit repetitive. That is why, I opted for giving directly the message in add_rejected_path(). Otherwise, I do agree an array would make things easier, especially for my patch. Does anyone has an objection into changing the struct unpack_trees_error_msgs into an array? -- 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