git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [Nit] Lots of enumerated type warnings
@ 2018-01-19 23:17 Randall S. Becker
  2018-01-22 22:41 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Randall S. Becker @ 2018-01-19 23:17 UTC (permalink / raw)
  To: git

So here a bit of a nit or nano-quibble that I have. Call it my "warnings
OCD" if you want. I'm seeing an increase in the enumerated type warnings
coming from my use of the c99 compiler for compiling git over time (loads
more for 2.16.0 compared to 2.3.7 when I took it on). What is the general
feeling on these? I would be willing do static casts rather than see the
warnings, mostly because I advocate in public that warnings are actually
future potential errors, so clean compiles are better. I don't see this
conflicting with anything in gcc. Is there a desire/need to clean up this
stuff? I can take a stab at gradually cleaning this up when $DAYJOB and
#FAMILY don't conflict.

Although, given the choice, I'd rather look into that whole --via concept
from a different thread ;-)

Cheers,
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.




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

* Re: [Nit] Lots of enumerated type warnings
  2018-01-19 23:17 [Nit] Lots of enumerated type warnings Randall S. Becker
@ 2018-01-22 22:41 ` Junio C Hamano
  2018-01-22 22:52   ` Randall S. Becker
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2018-01-22 22:41 UTC (permalink / raw)
  To: Randall S. Becker; +Cc: git

"Randall S. Becker" <rsbecker@nexbridge.com> writes:

> I'm seeing an increase in the enumerated type warnings
> coming from my use of the c99 compiler for compiling git over time (loads
> more for 2.16.0 compared to 2.3.7 when I took it on).

What exactly do these "warnings" complain about?  Without knowing
that, the remainder of your question cannot be answered.

Does it complain against enum FOO {A,B,C,} saying that the comma
after C is not kosher in older C standard, for example?


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

* RE: [Nit] Lots of enumerated type warnings
  2018-01-22 22:41 ` Junio C Hamano
@ 2018-01-22 22:52   ` Randall S. Becker
  2018-01-22 23:44     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Randall S. Becker @ 2018-01-22 22:52 UTC (permalink / raw)
  To: 'Junio C Hamano'; +Cc: git

On January 22, 2018 5:41 PM, Junio C Hamano wrote:
> "Randall S. Becker" <rsbecker@nexbridge.com> writes:
> 
> > I'm seeing an increase in the enumerated type warnings coming from my
> > use of the c99 compiler for compiling git over time (loads more for
> > 2.16.0 compared to 2.3.7 when I took it on).
> 
> What exactly do these "warnings" complain about?  Without knowing that,
> the remainder of your question cannot be answered.
> 
> Does it complain against enum FOO {A,B,C,} saying that the comma after C
is
> not kosher in older C standard, for example?

Here are a few examples, there are more:

auto_crlf = git_config_bool(var, value);
  		          ^
"/home/jenkins/.jenkins/workspace/Build_Git/config.c", line 1147:
warning(272): 
          enumerated type mixed with another type

type = sha1_object_info(s->oid.hash, &s->size);
  			     ^
"/home/jenkins/.jenkins/workspace/Build_Git/diff.c", line 3618:
warning(272): 
          enumerated type mixed with another type

options->color_moved = diff_color_moved_default;
  	                     ^
"/home/jenkins/.jenkins/workspace/Build_Git/diff.c", line 4108:
warning(272): 
          enumerated type mixed with another type

options->color_moved = 0;
  		                     ^
"/home/jenkins/.jenkins/workspace/Build_Git/diff.c", line 4218:
warning(272): 
          enumerated type mixed with another type


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

* Re: [Nit] Lots of enumerated type warnings
  2018-01-22 22:52   ` Randall S. Becker
@ 2018-01-22 23:44     ` Junio C Hamano
  2018-01-23  0:05       ` Randall S. Becker
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2018-01-22 23:44 UTC (permalink / raw)
  To: Randall S. Becker; +Cc: git

"Randall S. Becker" <rsbecker@nexbridge.com> writes:

> Here are a few examples, there are more:
>
> auto_crlf = git_config_bool(var, value);
>   		          ^

The carets in your message do not align to what I think they are
trying to point at, but I think the above is pointing at the '=' and
wants to say "auto_crlf variable is enum, it gets assigned an
integer returned from git_config_bool(), and I do not like that
assignment".

For this one I tend to agree with the compiler, meaning that it is
ugly to define "enum auto_crlf" in such a way that the first two
values happen to match what a logically different "enum" (which is
"boolean") assigns the two values to.  And this judgment does not
change whether git_config_bool() actually returns an enum or an int
(the code in reality returns the latter).

I do not think people would terribly mind a patch to turn the above
into:

  auto_crlf = git_config_bool(var, value) ? AUTO_CRLF_FALSE : AUTO_CRLF_TRUE;

> "/home/jenkins/.jenkins/workspace/Build_Git/config.c", line 1147:
> warning(272): 
>           enumerated type mixed with another type
>
> type = sha1_object_info(s->oid.hash, &s->size);
>   			     ^

/* returns enum object_type or negative */
int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)

The function has been like this forever, I suspect, and I would say
"this gives negative when error, or enum we know is non-negative" is
quite a reasonable thing to do, but the enum has OBJ_BAD defined to
be negative, so probably it is more kosher if sha1_object_info() is
declared to return "enum object_type" instead of int.

> "/home/jenkins/.jenkins/workspace/Build_Git/diff.c", line 3618:
> warning(272): 
>           enumerated type mixed with another type
>
> options->color_moved = diff_color_moved_default;
>   	                     ^

If color_moved field is declared to be an enum, the _default
variable should be, too.  I do not think it is such a controversial
fix.

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

* RE: [Nit] Lots of enumerated type warnings
  2018-01-22 23:44     ` Junio C Hamano
@ 2018-01-23  0:05       ` Randall S. Becker
  0 siblings, 0 replies; 5+ messages in thread
From: Randall S. Becker @ 2018-01-23  0:05 UTC (permalink / raw)
  To: 'Junio C Hamano'; +Cc: git

On January 22, 2018 6:44 PM, Junio C Hamano wrote:
> 
> "Randall S. Becker" <rsbecker@nexbridge.com> writes:
> 
> > Here are a few examples, there are more:
> >
> > auto_crlf = git_config_bool(var, value);
> >   		          ^
> 
> The carets in your message do not align to what I think they are trying to
> point at, but I think the above is pointing at the '=' and wants to say
> "auto_crlf variable is enum, it gets assigned an integer returned from
> git_config_bool(), and I do not like that assignment".
> 
> For this one I tend to agree with the compiler, meaning that it is ugly to
> define "enum auto_crlf" in such a way that the first two values happen to
> match what a logically different "enum" (which is
> "boolean") assigns the two values to.  And this judgment does not change
> whether git_config_bool() actually returns an enum or an int (the code in
> reality returns the latter).
> 
> I do not think people would terribly mind a patch to turn the above
> into:
> 
>   auto_crlf = git_config_bool(var, value) ? AUTO_CRLF_FALSE :
> AUTO_CRLF_TRUE;
> 
> > "/home/jenkins/.jenkins/workspace/Build_Git/config.c", line 1147:
> > warning(272):
> >           enumerated type mixed with another type
> >
> > type = sha1_object_info(s->oid.hash, &s->size);
> >   			     ^
> 
> /* returns enum object_type or negative */ int sha1_object_info(const
> unsigned char *sha1, unsigned long *sizep)
> 
> The function has been like this forever, I suspect, and I would say "this
gives
> negative when error, or enum we know is non-negative" is quite a
> reasonable thing to do, but the enum has OBJ_BAD defined to be negative,
> so probably it is more kosher if sha1_object_info() is declared to return
> "enum object_type" instead of int.
> 
> > "/home/jenkins/.jenkins/workspace/Build_Git/diff.c", line 3618:
> > warning(272):
> >           enumerated type mixed with another type
> >
> > options->color_moved = diff_color_moved_default;
> >   	                     ^
> 
> If color_moved field is declared to be an enum, the _default variable
should
> be, too.  I do not think it is such a controversial fix.

The basic idea of the request is whether to slowly take on this type of
change. It will likely take a bit of time, but I really don't like warnings,
so am willing to work on it. There are loads more like this that might need
discussion, so I'll be pretty conservative on this effort.

Cheers,
Randall


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

end of thread, other threads:[~2018-01-23  0:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 23:17 [Nit] Lots of enumerated type warnings Randall S. Becker
2018-01-22 22:41 ` Junio C Hamano
2018-01-22 22:52   ` Randall S. Becker
2018-01-22 23:44     ` Junio C Hamano
2018-01-23  0:05       ` Randall S. Becker

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).