Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] sindex: avoid a warning with 'case -1:'
@ 2020-07-04 23:54 Luc Van Oostenryck
  2020-07-05 11:12 ` Alexey Gladkov
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-07-04 23:54 UTC (permalink / raw)
  To: Alexey Gladkov; +Cc: linux-sparse, Luc Van Oostenryck

When parsing the format, there is a 'case -1:' which:
* seems to be there only for the following label (but mixing
  labels with cases, like here, is OK).
* on architectures where chars are unsigned, the compiler complains:
	warning: case label value is less than minimum value for type

So, remove the unneeded 'case -1:' and use an explicit 'default:'
to catch invalid formats. Also, align the label with the cases,
it looks nicer so.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 sindex.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sindex.c b/sindex.c
index ea092a4a434b..22836a957213 100644
--- a/sindex.c
+++ b/sindex.c
@@ -970,8 +970,8 @@ static int search_query_callback(void *data, int argc, char **argv, char **colna
 					print_file_line(argv[0], atoi(argv[1]));
 					fmt++;
 					break;
-				case -1:
-print_string:
+
+				print_string:
 					if (n) {
 						printf("%.*s", n, buf);
 						n = 0;
@@ -979,6 +979,9 @@ print_string:
 					printf("%s", argv[colnum]);
 					fmt++;
 					break;
+				default:
+					break;
+
 			}
 
 			if (pos == fmt)
-- 
2.27.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sindex: avoid a warning with 'case -1:'
  2020-07-04 23:54 [PATCH] sindex: avoid a warning with 'case -1:' Luc Van Oostenryck
@ 2020-07-05 11:12 ` Alexey Gladkov
  2020-07-05 11:45   ` Luc Van Oostenryck
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Gladkov @ 2020-07-05 11:12 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-sparse

On Sun, Jul 05, 2020 at 01:54:53AM +0200, Luc Van Oostenryck wrote:
> When parsing the format, there is a 'case -1:' which:
> * seems to be there only for the following label (but mixing
>   labels with cases, like here, is OK).
> * on architectures where chars are unsigned, the compiler complains:
> 	warning: case label value is less than minimum value for type
> 
> So, remove the unneeded 'case -1:' and use an explicit 'default:'
> to catch invalid formats. Also, align the label with the cases,
> it looks nicer so.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

Looks good :)

Reviewed-by: Alexey Gladkov <gladkov.alexey@gmail.com>

> ---
>  sindex.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/sindex.c b/sindex.c
> index ea092a4a434b..22836a957213 100644
> --- a/sindex.c
> +++ b/sindex.c
> @@ -970,8 +970,8 @@ static int search_query_callback(void *data, int argc, char **argv, char **colna
>  					print_file_line(argv[0], atoi(argv[1]));
>  					fmt++;
>  					break;
> -				case -1:
> -print_string:
> +
> +				print_string:
>  					if (n) {
>  						printf("%.*s", n, buf);
>  						n = 0;
> @@ -979,6 +979,9 @@ print_string:
>  					printf("%s", argv[colnum]);
>  					fmt++;
>  					break;
> +				default:
> +					break;
> +
>  			}
>  
>  			if (pos == fmt)
> -- 
> 2.27.0
> 

-- 
Rgrds, legion

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sindex: avoid a warning with 'case -1:'
  2020-07-05 11:12 ` Alexey Gladkov
@ 2020-07-05 11:45   ` Luc Van Oostenryck
  0 siblings, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-07-05 11:45 UTC (permalink / raw)
  To: Alexey Gladkov; +Cc: linux-sparse

On Sun, Jul 05, 2020 at 01:12:04PM +0200, Alexey Gladkov wrote:
> 
> Looks good :)
> 
> Reviewed-by: Alexey Gladkov <gladkov.alexey@gmail.com>

Thanks.
It's now pushed to the main tree.

-- Luc 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-04 23:54 [PATCH] sindex: avoid a warning with 'case -1:' Luc Van Oostenryck
2020-07-05 11:12 ` Alexey Gladkov
2020-07-05 11:45   ` Luc Van Oostenryck

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git