Re: [PATCH v17 13/14] tag.c: implement '--format' option

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

 



Karthik Nayak <karthik.188@xxxxxxxxx> writes:

> -static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting)
> +static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, const char *format)
>  {
>  	struct ref_array array;
> -	char *format, *to_free = NULL;
> +	char *to_free = NULL;
>  	int i;

format is const char * while to_free is non-const char * here.

> @@ -41,12 +41,14 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting)
>  	if (filter->lines == -1)
>  		filter->lines = 0;
>  
> +	if (!format) {
> +		if (filter->lines) {
> +			format = xstrfmt("%s %%(contents:lines=%d)",
> +					 "%(align:15)%%(refname:short)%%(end)", filter->lines);

Hmmm, did this even pass tests and if so how?  What are these double
%% doing before refname and end?  Perhaps we do not have enough test
coverage?

> +			to_free = format;

This assignment discards constness.

Take the result of xstrfmt() to to_free (which is a non-const
pointer) and then assigning it to format (which is a const pointer)
would work it around.
--
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]