git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Fix minor warnings reported by icc
@ 2011-11-15 16:59 Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 1/4] http: remove unused function hex() Ramkumar Ramachandra
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 16:59 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Hi,

Thomas Rast tried compiling Git with Intel's C compiler (icc) recently
and the results can be found here [1].  Most of them don't amount to
anything, are probably not worth fixing.  Here are fixes to a few that
caught my eye.

Thanks.

[1]: https://gist.github.com/1367335

-- Ram

Ramkumar Ramachandra (4):
  http: remove unused function hex()
  convert: don't mix enum with int
  ll-merge: initialize default_opts const
  sha1_file: don't mix enum with int

 convert.c   |    6 +++---
 http.c      |    8 --------
 ll-merge.c  |    2 +-
 sha1_file.c |    2 +-
 4 files changed, 5 insertions(+), 13 deletions(-)

-- 
1.7.6.351.gb35ac.dirty

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

* [PATCH 1/4] http: remove unused function hex()
  2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
@ 2011-11-15 16:59 ` Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 2/4] convert: don't mix enum with int Ramkumar Ramachandra
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 16:59 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 http.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/http.c b/http.c
index 008ad72..e6c7597 100644
--- a/http.c
+++ b/http.c
@@ -747,14 +747,6 @@ static inline int needs_quote(int ch)
 	return 1;
 }
 
-static inline int hex(int v)
-{
-	if (v < 10)
-		return '0' + v;
-	else
-		return 'A' + v - 10;
-}
-
 static char *quote_ref_url(const char *base, const char *ref)
 {
 	struct strbuf buf = STRBUF_INIT;
-- 
1.7.6.351.gb35ac.dirty

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

* [PATCH 2/4] convert: don't mix enum with int
  2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 1/4] http: remove unused function hex() Ramkumar Ramachandra
@ 2011-11-15 16:59 ` Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 3/4] ll-merge: initialize default_opts const Ramkumar Ramachandra
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 16:59 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 convert.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/convert.c b/convert.c
index 3bb5a4d..038b0be 100644
--- a/convert.c
+++ b/convert.c
@@ -641,7 +641,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
 	return 1;
 }
 
-static int git_path_check_crlf(const char *path, struct git_attr_check *check)
+static enum crlf_action git_path_check_crlf(const char *path, struct git_attr_check *check)
 {
 	const char *value = check->value;
 
@@ -658,7 +658,7 @@ static int git_path_check_crlf(const char *path, struct git_attr_check *check)
 	return CRLF_GUESS;
 }
 
-static int git_path_check_eol(const char *path, struct git_attr_check *check)
+static enum crlf_action git_path_check_eol(const char *path, struct git_attr_check *check)
 {
 	const char *value = check->value;
 
@@ -811,7 +811,7 @@ int renormalize_buffer(const char *path, const char *src, size_t len, struct str
 		src = dst->buf;
 		len = dst->len;
 	}
-	return ret | convert_to_git(path, src, len, dst, 0);
+	return ret | convert_to_git(path, src, len, dst, SAFE_CRLF_FALSE);
 }
 
 /*****************************************************************
-- 
1.7.6.351.gb35ac.dirty

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

* [PATCH 3/4] ll-merge: initialize default_opts const
  2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 1/4] http: remove unused function hex() Ramkumar Ramachandra
  2011-11-15 16:59 ` [PATCH 2/4] convert: don't mix enum with int Ramkumar Ramachandra
@ 2011-11-15 16:59 ` Ramkumar Ramachandra
  2011-11-15 23:17   ` Junio C Hamano
  2011-11-15 16:59 ` [PATCH 4/4] sha1_file: don't mix enum with int Ramkumar Ramachandra
  2011-11-15 17:31 ` [PATCH 5/4] git-compat-util: don't assume value for undefined variable Ramkumar Ramachandra
  4 siblings, 1 reply; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 16:59 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 ll-merge.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ll-merge.c b/ll-merge.c
index da59738..205aed3 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -351,7 +351,7 @@ int ll_merge(mmbuffer_t *result_buf,
 	     const struct ll_merge_options *opts)
 {
 	static struct git_attr_check check[2];
-	static const struct ll_merge_options default_opts;
+	static const struct ll_merge_options default_opts = {0, 0, 0, 0};
 	const char *ll_driver_name = NULL;
 	int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
 	const struct ll_merge_driver *driver;
-- 
1.7.6.351.gb35ac.dirty

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

* [PATCH 4/4] sha1_file: don't mix enum with int
  2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
                   ` (2 preceding siblings ...)
  2011-11-15 16:59 ` [PATCH 3/4] ll-merge: initialize default_opts const Ramkumar Ramachandra
@ 2011-11-15 16:59 ` Ramkumar Ramachandra
  2011-11-15 17:31 ` [PATCH 5/4] git-compat-util: don't assume value for undefined variable Ramkumar Ramachandra
  4 siblings, 0 replies; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 16:59 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sha1_file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 27f3b9b..869852b 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2616,7 +2616,7 @@ static int index_mem(unsigned char *sha1, void *buf, size_t size,
 	if ((type == OBJ_BLOB) && path) {
 		struct strbuf nbuf = STRBUF_INIT;
 		if (convert_to_git(path, buf, size, &nbuf,
-		                   write_object ? safe_crlf : 0)) {
+		                   write_object ? safe_crlf : SAFE_CRLF_FALSE)) {
 			buf = strbuf_detach(&nbuf, &size);
 			re_allocated = 1;
 		}
-- 
1.7.6.351.gb35ac.dirty

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

* [PATCH 5/4] git-compat-util: don't assume value for undefined variable
  2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
                   ` (3 preceding siblings ...)
  2011-11-15 16:59 ` [PATCH 4/4] sha1_file: don't mix enum with int Ramkumar Ramachandra
@ 2011-11-15 17:31 ` Ramkumar Ramachandra
  4 siblings, 0 replies; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-15 17:31 UTC (permalink / raw)
  To: Git List; +Cc: Thomas Rast

Suggested-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 And here's another probably worth fixing.

 git-compat-util.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 5ef8ff7..8b4dd5c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -219,7 +219,7 @@ extern char *gitbasename(char *);
 #define find_last_dir_sep(path) strrchr(path, '/')
 #endif
 
-#if __HP_cc >= 61000
+#if defined(__HP_cc) && (__HP_cc >= 61000)
 #define NORETURN __attribute__((noreturn))
 #define NORETURN_PTR
 #elif defined(__GNUC__) && !defined(NO_NORETURN)
-- 
1.7.6.351.gb35ac.dirty

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

* Re: [PATCH 3/4] ll-merge: initialize default_opts const
  2011-11-15 16:59 ` [PATCH 3/4] ll-merge: initialize default_opts const Ramkumar Ramachandra
@ 2011-11-15 23:17   ` Junio C Hamano
  2011-11-16  6:06     ` Ramkumar Ramachandra
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2011-11-15 23:17 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Thomas Rast

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  ll-merge.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/ll-merge.c b/ll-merge.c
> index da59738..205aed3 100644
> --- a/ll-merge.c
> +++ b/ll-merge.c
> @@ -351,7 +351,7 @@ int ll_merge(mmbuffer_t *result_buf,
>  	     const struct ll_merge_options *opts)
>  {
>  	static struct git_attr_check check[2];
> -	static const struct ll_merge_options default_opts;
> +	static const struct ll_merge_options default_opts = {0, 0, 0, 0};

Doesn't "static" tell us that it will be in BSS, initialized to all zero
by definition?

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

* Re: [PATCH 3/4] ll-merge: initialize default_opts const
  2011-11-15 23:17   ` Junio C Hamano
@ 2011-11-16  6:06     ` Ramkumar Ramachandra
  2011-11-16  7:49       ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Ramkumar Ramachandra @ 2011-11-16  6:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Thomas Rast

Hi Junio,

Junio C Hamano wrote:
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>> [...]
>> diff --git a/ll-merge.c b/ll-merge.c
>> index da59738..205aed3 100644
>> --- a/ll-merge.c
>> +++ b/ll-merge.c
>> @@ -351,7 +351,7 @@ int ll_merge(mmbuffer_t *result_buf,
>>            const struct ll_merge_options *opts)
>>  {
>>       static struct git_attr_check check[2];
>> -     static const struct ll_merge_options default_opts;
>> +     static const struct ll_merge_options default_opts = {0, 0, 0, 0};
>
> Doesn't "static" tell us that it will be in BSS, initialized to all zero
> by definition?

I'm uncertain about whether the C89 standard says this explicitly- icc
is more pedantic than most mainstream compilers.  Feel free to drop
this part if you don't think it adds value.

Thanks.

-- Ram

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

* Re: [PATCH 3/4] ll-merge: initialize default_opts const
  2011-11-16  6:06     ` Ramkumar Ramachandra
@ 2011-11-16  7:49       ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2011-11-16  7:49 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Junio C Hamano, Git List, Thomas Rast

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Hi Junio,
>
> Junio C Hamano wrote:
>> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>>> [...]
>>> -     static const struct ll_merge_options default_opts;
>>> +     static const struct ll_merge_options default_opts = {0, 0, 0, 0};
>>
>> Doesn't "static" tell us that it will be in BSS, initialized to all zero
>> by definition?
>
> I'm uncertain about whether the C89 standard says this explicitly- icc
> is more pedantic than most mainstream compilers.

Actually I take a part of the comment back; as this is "static const", it
is entirely plausible for a compiler to tell the linker to put it in rodata
instead of bss, to cause any attempt to modify it to segv.

A datum that is implicitly initialized to all zero and not allowed to be
modified might appear suspect to some compiler writers (especially when
they are under influence ;-)), so I am not so surprised if a compiler
issued a warning saying "did you forget to initialize it?".

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

end of thread, other threads:[~2011-11-16  7:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15 16:59 [PATCH 0/4] Fix minor warnings reported by icc Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 1/4] http: remove unused function hex() Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 2/4] convert: don't mix enum with int Ramkumar Ramachandra
2011-11-15 16:59 ` [PATCH 3/4] ll-merge: initialize default_opts const Ramkumar Ramachandra
2011-11-15 23:17   ` Junio C Hamano
2011-11-16  6:06     ` Ramkumar Ramachandra
2011-11-16  7:49       ` Junio C Hamano
2011-11-15 16:59 ` [PATCH 4/4] sha1_file: don't mix enum with int Ramkumar Ramachandra
2011-11-15 17:31 ` [PATCH 5/4] git-compat-util: don't assume value for undefined variable Ramkumar Ramachandra

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 NNTP newsgroup(s).