Re: [PATCH 1/2] help: add help_unknown_ref

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

 



Vikrant Varma <vikrant.varma94@xxxxxxxxx> writes:

> On 02-05-2013 02:02, Ramkumar Ramachandra wrote:
>>> ref_cb.similar_refs has already been defined. The compiler won't let me
>>> assign to it unless I cast first. However, I think compound literals are a
>>> C99/gcc feature. Is this better?
>>>
>>>          struct similar_ref_cb ref_cb = {ref, STRING_LIST_INIT_NODUP};
>>
>> As Johannes pointed out, ref is a variable and that is problematic.
>> Leave the cast on: I didn't notice the compiler warning in my head.
>>
> Is it okay to use a compound literal? It's not supported in C89.

Building on top of what was suggested in the other message, the
helper could be made more reusable by doing something like this:

	int suggest_misspelt_ref(const char *ref, struct string_list *suggested);

and the caller can do

	if (!commit) {
		struct string_list suggested = STRING_LIST_INIT;
                if (suggest_misspelt_ref(argv[1], &suggested)) {
                	... Did you mean one of these??? ...
			string_list_clear(&suggested);
		}
                die(_("'%s' is not something we can merge'), argv[1]);
	}

So I think this point is moot.  Of course, similar_ref_cb needs to
be updated to keep a pointer to an existing string_list, not an
instance of its own string_list.



--
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]