git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
@ 2011-03-16  2:49 Jonathan Nieder
  2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  2:49 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Jeff King

Date: Fri, 04 Mar 2011 00:54:53 -0600

Starting with gcc 4.5 (r147852, Pretty-ipa merge: Inliner heruistics
reorg, 2009-05-25), gcc -O3 -Wall warns when building
reflog_expire_config:

    warning: 'expire' may be used uninitialized in this function [-Wuninitialized]

The cause: starting with that version, gcc realizes it can inline the
call to parse_expire_cfg_value.  In the error case, 'expire' is not
initialized and the function returns early, but gcc does not have
enough information to figure out that this is an error return.

Squash the warning by letting the optimizer peek at the return value
from config_error_nonbool.  This also decreases the text size by a
tiny (negligible) amount when building with -Os --- before:

    text    data     bss     dec     hex filename
 1002184   24856  316928 1343968  1481e0 git

After:

    text    data     bss     dec     hex filename
 1002120   24856  316928 1343904  1481a0 git

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,

Another patch that was sitting around in my tree.  (I had the somewhat
insane idea of turning on as many warnings as feasible and getting git
to build with -Werror.  The effect on running time for tests was
encouraging but within noise.)

While it might make sense to do something like this for error()
itself, I don't know a clean and portable way to make a variadic macro
or inline function.

Anyway, maybe this can provide some amusement.

 cache.h  |    8 +++++++-
 config.c |    4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index c4ef999..c8ce53a 100644
--- a/cache.h
+++ b/cache.h
@@ -1022,10 +1022,16 @@ extern int check_repository_format_version(const char *var, const char *value, v
 extern int git_env_bool(const char *, int);
 extern int git_config_system(void);
 extern int git_config_global(void);
-extern int config_error_nonbool(const char *);
 extern const char *get_log_output_encoding(void);
 extern const char *get_commit_output_encoding(void);
 
+extern void config_print_error_nonbool(const char *);
+static inline int config_error_nonbool(const char *var)
+{
+	config_print_error_nonbool(var);
+	return -1;
+}
+
 extern const char *config_exclusive_filename;
 
 #define MAX_GITNAME (1000)
diff --git a/config.c b/config.c
index b94de8f..cf41c1c 100644
--- a/config.c
+++ b/config.c
@@ -1506,7 +1506,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
  * Call this to report error for your variable that should not
  * get a boolean value (i.e. "[my] var" means "true").
  */
-int config_error_nonbool(const char *var)
+void config_print_error_nonbool(const char *var)
 {
-	return error("Missing value for '%s'", var);
+	error("Missing value for '%s'", var);
 }
-- 
1.7.4.1

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

* [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned
  2011-03-16  2:49 [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Jonathan Nieder
@ 2011-03-16  3:42 ` Jonathan Nieder
  2011-03-16  5:38   ` Junio C Hamano
  2011-03-16 14:20   ` Nguyen Thai Ngoc Duy
  2011-03-16  5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
  2 siblings, 2 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  3:42 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

As "gcc -pedantic" notices, a two's complement 1-bit signed integer
cannot represent the value '1'.

 dir.c: In function 'init_pathspec':
 dir.c:1291:4: warning: overflow in implicit constant conversion [-Woverflow]

In the spirit of v1.7.1-rc1~10 (2010-04-06), 'unsigned' is what was
intended, so let's make the flags unsigned.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Jonathan Nieder wrote:

> I had the somewhat
> insane idea of turning on as many warnings as feasible and getting git
> to build with -Werror.

Here's another one.  Based against f577b92 from master (aka
nd/struct-pathspec).

 cache.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index 4beb2dc..edd5b5a 100644
--- a/cache.h
+++ b/cache.h
@@ -503,13 +503,13 @@ extern int ie_modified(const struct index_state *, struct cache_entry *, struct
 struct pathspec {
 	const char **raw; /* get_pathspec() result, not freed by free_pathspec() */
 	int nr;
-	int has_wildcard:1;
-	int recursive:1;
+	unsigned int has_wildcard:1;
+	unsigned int recursive:1;
 	int max_depth;
 	struct pathspec_item {
 		const char *match;
 		int len;
-		int has_wildcard:1;
+		unsigned int has_wildcard:1;
 	} *items;
 };
 
-- 
1.7.4.1

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  2:49 [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Jonathan Nieder
  2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
@ 2011-03-16  5:22 ` Junio C Hamano
  2011-03-16  6:28   ` Jonathan Nieder
  2011-03-16  9:09   ` Johannes Sixt
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
  2 siblings, 2 replies; 34+ messages in thread
From: Junio C Hamano @ 2011-03-16  5:22 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Jeff King

Jonathan Nieder <jrnieder@gmail.com> writes:

> Date: Fri, 04 Mar 2011 00:54:53 -0600
>
> Starting with gcc 4.5 (r147852, Pretty-ipa merge: Inliner heruistics
> reorg, 2009-05-25), gcc -O3 -Wall warns when building
> reflog_expire_config:
>
>     warning: 'expire' may be used uninitialized in this function [-Wuninitialized]
>
> The cause: starting with that version, gcc realizes it can inline the
> call to parse_expire_cfg_value.  In the error case, 'expire' is not
> initialized and the function returns early, but gcc does not have
> enough information to figure out that this is an error return.
> ...
> Anyway, maybe this can provide some amusement.

It actually provides only puzzlement.  That is obviously a buggy compiler
whose warning cannot be trusted.

I am not suggesting to work this around on the caller side, but I wonder
what effect the usual workaround to tell the compiler that we know it
doesn't understand the validity of this variable by saying:

	unsigned long expire = expire;

have on this?

We obviously do not want to work the compiler bug around in the callee
side by assigning to the variable when we didn't parse anything, but the
change to inline config_error_nonbool() to force this particular version
of the compiler to see the callchain through is _too_ subtle for my taste.
The call-chain horizon the next version of the compiler may stop looking
may be different, potentially shifting the compiler bug around.

I see two solutions (1) do not use -Wunitialized if the compiler is known
to be broken, or (2) initialize the variable to 0 (not the fake "x = x")
on the caller side at the place of the definition (yes, we would waste one
real assignment) if we really need to work this around, or (3) take this
patch.

We could obviously do (2) or (3), but the thing is, I don't think we can
have much confidence on -Wuninitialized warnings from this compiler once
we go down that route.  Is it _guaranteed_ that the compiler bug _always_
err on the false-positive side?

IOW, I'd very much prefer (1) for this particular case and if somebody
really cares (2).

Well, it indeed turned out to be amusing, at least for some definition of
the word ;-). I was starting to feel somewhat depressed watching news
programs from Japan on ustream.

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

* Re: [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned
  2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
@ 2011-03-16  5:38   ` Junio C Hamano
  2011-03-16 14:20   ` Nguyen Thai Ngoc Duy
  1 sibling, 0 replies; 34+ messages in thread
From: Junio C Hamano @ 2011-03-16  5:38 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Nguyễn Thái Ngọc Duy

Jonathan Nieder <jrnieder@gmail.com> writes:

> As "gcc -pedantic" notices, a two's complement 1-bit signed integer
> cannot represent the value '1'.

Thanks; this is one of the things I try to be reasonably careful about
when I eyeball patches, but apparently I didn't spot it.

Perhaps I should start compiling with -Woverflow.

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
@ 2011-03-16  6:28   ` Jonathan Nieder
  2011-03-16  9:09   ` Johannes Sixt
  1 sibling, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  6:28 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Jeff King

Junio C Hamano wrote:

> We could obviously do (2) or (3), but the thing is, I don't think we can
> have much confidence on -Wuninitialized warnings from this compiler once
> we go down that route.  Is it _guaranteed_ that the compiler bug _always_
> err on the false-positive side?
>
> IOW, I'd very much prefer (1) for this particular case and if somebody
> really cares (2).

*nod*.  The tricky heuristics here are that (A) a call to the function

 extern void foo(int *var);

is assumed to initialize *var (to support idioms like strbuf_init), while
(B) no assumption is made about the return value of a call to the function

 extern int bar(void);

The assumption (B) is the scourge of -Wuninitialized users.  It is
always going produce a lot of false positives --- the compiler simply
doesn't have enough information to completely analyze the flow through
a function.  (Even if it did have enough information, completely
solving the problem is Turing-complete.)

Problems from (A) are more rare.  -Wuninitialized will produce _some_
false negatives, but problems it misses would typically be due to
failure to check for errors and return early, which is not what
-Wuninitialized is about.

I don't mind the warning, especially since it only appears with -O3.
What makes this interesting to me is that it is a reminder that the
compiler has very little information about the flow of control.  A
simple

 #define error(...) (report_error(__VA_ARGS__), -1)

could open the door to some nice micro-optimizations.

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

* [PATCH 0/8] more warnings and cleanups
  2011-03-16  2:49 [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Jonathan Nieder
  2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
  2011-03-16  5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
@ 2011-03-16  6:53 ` Jonathan Nieder
  2011-03-16  6:59   ` [PATCH 1/8] enums: omit trailing comma for portability Jonathan Nieder
                     ` (7 more replies)
  2 siblings, 8 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  6:53 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano

Here are some more patches in the same vein.

Patches 1-4 fix style problems noticed with make CC="c89 -pedantic"
(mostly concerning the -pedantic rather than the c89).

Patch 5 updates fast-import.c (and everyone else) to put braces on the
same line as "struct foo" --- the waste of space had bothered me every
time I hacked on fast-import.c so now is my chance. :)

Patches 6-8 factor out some new functions to un-indent code a little.
The indented code was discovered in changing

	struct pretty_print_ctx ctx = {0};

into something more verbose to appease gcc -Wmissing-field-initializers,
which probably wasn't a good idea after all. :)  But the by-product is
nice.

Jonathan Nieder (8):
  enums: omit trailing comma for portability
  compat: make gcc bswap an inline function
  svn-fe: do not use "return" for tail call returning void
  vcs-svn: remove spurious semicolons
  standardize brace placement in struct definitions
  branch: split off function that writes tracking info and commit
    subject
  cherry: split off function to print output lines
  diff --submodule: split into bite-sized pieces

 builtin/add.c         |    3 +-
 builtin/blame.c       |    3 +-
 builtin/branch.c      |   48 +++++++++++++----------
 builtin/grep.c        |    3 +-
 builtin/index-pack.c  |    6 +--
 builtin/log.c         |   34 +++++++++--------
 cache.h               |    2 +-
 commit.h              |    3 +-
 compat/bswap.h        |   18 +++++----
 config.c              |    3 +-
 convert.c             |    2 +-
 diff.c                |    6 +--
 fast-import.c         |   42 +++++++-------------
 http-push.c           |   15 ++-----
 http-walker.c         |    6 +--
 http.h                |   15 ++-----
 merge-recursive.c     |   12 ++----
 pack-check.c          |    3 +-
 string-list.h         |    3 +-
 submodule.c           |  103 +++++++++++++++++++++++++++++--------------------
 transport-helper.c    |    3 +-
 vcs-svn/repo_tree.c   |    2 +-
 vcs-svn/string_pool.c |    2 +-
 vcs-svn/svndump.c     |    3 +-
 24 files changed, 164 insertions(+), 176 deletions(-)

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

* [PATCH 1/8] enums: omit trailing comma for portability
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
@ 2011-03-16  6:59   ` Jonathan Nieder
  2011-03-16  7:00   ` [PATCH 2/8] compat: make gcc bswap an inline function Jonathan Nieder
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  6:59 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Eyvind Bernhardsen, Gary V. Vaughan

Since v1.7.2-rc0~23^2~2 (Add per-repository eol normalization,
2010-05-19), building with gcc -std=gnu89 -pedantic produces warnings
like the following:

 convert.c:21:11: warning: comma at end of enumerator list [-pedantic]

gcc is right to complain --- these commas are not permitted in C89.
In the spirit of v1.7.2-rc0~32^2~16 (2010-05-14), remove them.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
At first, I was worried that the fixes from the series v1.7.2-rc0~32
had been in vain, but in reality it seems that there are only a few
new C89-compatibility tweaks to make like this one.

 cache.h   |    2 +-
 convert.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cache.h b/cache.h
index c4ef999..80f1236 100644
--- a/cache.h
+++ b/cache.h
@@ -585,7 +585,7 @@ extern enum safe_crlf safe_crlf;
 enum auto_crlf {
 	AUTO_CRLF_FALSE = 0,
 	AUTO_CRLF_TRUE = 1,
-	AUTO_CRLF_INPUT = -1,
+	AUTO_CRLF_INPUT = -1
 };
 
 extern enum auto_crlf auto_crlf;
diff --git a/convert.c b/convert.c
index d5aebed..7eb51b1 100644
--- a/convert.c
+++ b/convert.c
@@ -18,7 +18,7 @@ enum action {
 	CRLF_TEXT,
 	CRLF_INPUT,
 	CRLF_CRLF,
-	CRLF_AUTO,
+	CRLF_AUTO
 };
 
 struct text_stat {
-- 
1.7.4.1

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

* [PATCH 2/8] compat: make gcc bswap an inline function
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
  2011-03-16  6:59   ` [PATCH 1/8] enums: omit trailing comma for portability Jonathan Nieder
@ 2011-03-16  7:00   ` Jonathan Nieder
  2011-03-16  9:21     ` Johannes Sixt
  2011-03-16  7:01   ` [PATCH 3/8] svn-fe: do not use "return" for tail call returning void Jonathan Nieder
                     ` (5 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:00 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Nicolas Pitre

Without this change, gcc -pedantic warns:

 cache.h: In function 'ce_to_dtype':
 cache.h:270:21: warning: ISO C forbids braced-groups within expressions [-pedantic]

An inline function is more readable anyway.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 compat/bswap.h |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/compat/bswap.h b/compat/bswap.h
index 54756db..5061214 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -21,14 +21,16 @@ static inline uint32_t default_swab32(uint32_t val)
 
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
-#define bswap32(x) ({ \
-	uint32_t __res; \
-	if (__builtin_constant_p(x)) { \
-		__res = default_swab32(x); \
-	} else { \
-		__asm__("bswap %0" : "=r" (__res) : "0" ((uint32_t)(x))); \
-	} \
-	__res; })
+#define bswap32 git_bswap32
+static inline uint32_t git_bswap32(uint32_t x)
+{
+	uint32_t result;
+	if (__builtin_constant_p(x))
+		result = default_swab32(x);
+	else
+		__asm__("bswap %0" : "=r" (result) : "0" (x));
+	return result;
+}
 
 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
 
-- 
1.7.4.1

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

* [PATCH 3/8] svn-fe: do not use "return" for tail call returning void
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
  2011-03-16  6:59   ` [PATCH 1/8] enums: omit trailing comma for portability Jonathan Nieder
  2011-03-16  7:00   ` [PATCH 2/8] compat: make gcc bswap an inline function Jonathan Nieder
@ 2011-03-16  7:01   ` Jonathan Nieder
  2011-03-16  7:02   ` [PATCH 4/8] vcs-svn: remove spurious semicolons Jonathan Nieder
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:01 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano

As v1.7.4-rc0~184 (2010-10-04) reminds us, a void function shouldn't
try to return something.

Noticed with gcc -pedantic:

 vcs-svn/svndump.c: In function 'handle_node':
 vcs-svn/svndump.c:213:3: warning: ISO C forbids 'return' with expression,
  in function returning void [-pedantic]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 vcs-svn/svndump.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index ee7c0bb..3a0a75e 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -210,7 +210,8 @@ static void handle_node(void)
 		if (mark || have_props || node_ctx.srcRev)
 			die("invalid dump: deletion node has "
 				"copyfrom info, text, or properties");
-		return repo_delete(node_ctx.dst);
+		repo_delete(node_ctx.dst);
+		return;
 	}
 	if (node_ctx.action == NODEACT_REPLACE) {
 		repo_delete(node_ctx.dst);
-- 
1.7.4.1

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

* [PATCH 4/8] vcs-svn: remove spurious semicolons
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
                     ` (2 preceding siblings ...)
  2011-03-16  7:01   ` [PATCH 3/8] svn-fe: do not use "return" for tail call returning void Jonathan Nieder
@ 2011-03-16  7:02   ` Jonathan Nieder
  2011-03-16 19:47     ` Junio C Hamano
  2011-03-16  7:08   ` [PATCH 5/8] standardize brace placement in struct definitions Jonathan Nieder
                     ` (3 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:02 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Ramkumar Ramachandra

trp_gen is not a statement or function call, so it should not be
followed with a semicolon.  Noticed by gcc -pedantic.

 vcs-svn/repo_tree.c:41:81: warning: ISO C does not allow extra ';'
  outside of a function [-pedantic]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 vcs-svn/repo_tree.c   |    2 +-
 vcs-svn/string_pool.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c
index 491f013..207ffc3 100644
--- a/vcs-svn/repo_tree.c
+++ b/vcs-svn/repo_tree.c
@@ -38,7 +38,7 @@ static uint32_t mark;
 static int repo_dirent_name_cmp(const void *a, const void *b);
 
 /* Treap for directory entries */
-trp_gen(static, dent_, struct repo_dirent, children, dent, repo_dirent_name_cmp);
+trp_gen(static, dent_, struct repo_dirent, children, dent, repo_dirent_name_cmp)
 
 uint32_t next_blob_mark(void)
 {
diff --git a/vcs-svn/string_pool.c b/vcs-svn/string_pool.c
index f5b1da8..8af8d54 100644
--- a/vcs-svn/string_pool.c
+++ b/vcs-svn/string_pool.c
@@ -30,7 +30,7 @@ static int node_cmp(struct node *a, struct node *b)
 }
 
 /* Build a Treap from the node structure (a trp_node w/ offset) */
-trp_gen(static, tree_, struct node, children, node, node_cmp);
+trp_gen(static, tree_, struct node, children, node, node_cmp)
 
 const char *pool_fetch(uint32_t entry)
 {
-- 
1.7.4.1

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

* [PATCH 5/8] standardize brace placement in struct definitions
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
                     ` (3 preceding siblings ...)
  2011-03-16  7:02   ` [PATCH 4/8] vcs-svn: remove spurious semicolons Jonathan Nieder
@ 2011-03-16  7:08   ` Jonathan Nieder
  2011-03-18  7:25     ` Junio C Hamano
  2011-03-16  7:10   ` [PATCH 6/8] branch: split off function that writes tracking info and commit subject Jonathan Nieder
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:08 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Shawn O. Pearce

In a struct definitions, unlike functions, the prevailing style is for
the opening brace to go on the same line as the struct name, like so:

 struct foo {
	int bar;
	char *baz;
 };

Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many
matches as 'struct [a-z_]*$'.

Linus sayeth:

 Heretic people all over the world have claimed that this inconsistency
 is ...  well ...  inconsistent, but all right-thinking people know that
 (a) K&R are _right_ and (b) K&R are right.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
The real reason: when I read through fast-import I end up wishing I
could fit more struct definitions in my 31-line terminal.

 builtin/add.c        |    3 +--
 builtin/blame.c      |    3 +--
 builtin/grep.c       |    3 +--
 builtin/index-pack.c |    6 ++----
 commit.h             |    3 +--
 config.c             |    3 +--
 diff.c               |    6 ++----
 fast-import.c        |   42 ++++++++++++++----------------------------
 fetch-pack.h         |    3 +--
 generate-cmdlist.sh  |    3 +--
 http-push.c          |   15 +++++----------
 http-walker.c        |    6 ++----
 http.h               |   15 +++++----------
 merge-recursive.c    |   12 ++++--------
 pack-check.c         |    3 +--
 string-list.h        |    3 +--
 transport-helper.c   |    3 +--
 17 files changed, 44 insertions(+), 88 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index f7a17e4..e127d5a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -21,8 +21,7 @@ static const char * const builtin_add_usage[] = {
 static int patch_interactive, add_interactive, edit_interactive;
 static int take_worktree_changes;
 
-struct update_callback_data
-{
+struct update_callback_data {
 	int flags;
 	int add_errors;
 };
diff --git a/builtin/blame.c b/builtin/blame.c
index aa30ec5..f6b03f7 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1312,8 +1312,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
 /*
  * Information on commits, used for output.
  */
-struct commit_info
-{
+struct commit_info {
 	const char *author;
 	const char *author_mail;
 	unsigned long author_time;
diff --git a/builtin/grep.c b/builtin/grep.c
index 5afee2f..eaf8560 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -40,8 +40,7 @@ enum work_type {WORK_SHA1, WORK_FILE};
  * threads. The producer adds struct work_items to 'todo' and the
  * consumers pick work items from the same array.
  */
-struct work_item
-{
+struct work_item {
 	enum work_type type;
 	char *name;
 
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8dc5c0b..c7e600d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -13,8 +13,7 @@
 static const char index_pack_usage[] =
 "git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
 
-struct object_entry
-{
+struct object_entry {
 	struct pack_idx_entry idx;
 	unsigned long size;
 	unsigned int hdr_size;
@@ -44,8 +43,7 @@ struct base_data {
 #define FLAG_LINK (1u<<20)
 #define FLAG_CHECKED (1u<<21)
 
-struct delta_entry
-{
+struct delta_entry {
 	union delta_base base;
 	int obj_no;
 };
diff --git a/commit.h b/commit.h
index 659c87c..4198513 100644
--- a/commit.h
+++ b/commit.h
@@ -68,8 +68,7 @@ enum cmit_fmt {
 	CMIT_FMT_UNSPECIFIED
 };
 
-struct pretty_print_context
-{
+struct pretty_print_context {
 	int abbrev;
 	const char *subject;
 	const char *after_subject;
diff --git a/config.c b/config.c
index b94de8f..fa740a6 100644
--- a/config.c
+++ b/config.c
@@ -20,8 +20,7 @@ static int zlib_compression_seen;
 
 const char *config_exclusive_filename = NULL;
 
-struct config_item
-{
+struct config_item {
 	struct config_item *next;
 	char *name;
 	char *value;
diff --git a/diff.c b/diff.c
index 6640857..3fd9e0c 100644
--- a/diff.c
+++ b/diff.c
@@ -615,16 +615,14 @@ static void diff_words_append(char *line, unsigned long len,
 	buffer->text.ptr[buffer->text.size] = '\0';
 }
 
-struct diff_words_style_elem
-{
+struct diff_words_style_elem {
 	const char *prefix;
 	const char *suffix;
 	const char *color; /* NULL; filled in by the setup code if
 			    * color is enabled */
 };
 
-struct diff_words_style
-{
+struct diff_words_style {
 	enum diff_words_type type;
 	struct diff_words_style_elem new, old, ctx;
 	const char *newline;
diff --git a/fast-import.c b/fast-import.c
index e24ee2c..d9f9a3f 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -170,8 +170,7 @@ Format of STDIN stream:
 #define DEPTH_BITS 13
 #define MAX_DEPTH ((1<<DEPTH_BITS)-1)
 
-struct object_entry
-{
+struct object_entry {
 	struct pack_idx_entry idx;
 	struct object_entry *next;
 	uint32_t type : TYPE_BITS,
@@ -179,16 +178,14 @@ struct object_entry
 		depth : DEPTH_BITS;
 };
 
-struct object_entry_pool
-{
+struct object_entry_pool {
 	struct object_entry_pool *next_pool;
 	struct object_entry *next_free;
 	struct object_entry *end;
 	struct object_entry entries[FLEX_ARRAY]; /* more */
 };
 
-struct mark_set
-{
+struct mark_set {
 	union {
 		struct object_entry *marked[1024];
 		struct mark_set *sets[1024];
@@ -196,57 +193,49 @@ struct mark_set
 	unsigned int shift;
 };
 
-struct last_object
-{
+struct last_object {
 	struct strbuf data;
 	off_t offset;
 	unsigned int depth;
 	unsigned no_swap : 1;
 };
 
-struct mem_pool
-{
+struct mem_pool {
 	struct mem_pool *next_pool;
 	char *next_free;
 	char *end;
 	uintmax_t space[FLEX_ARRAY]; /* more */
 };
 
-struct atom_str
-{
+struct atom_str {
 	struct atom_str *next_atom;
 	unsigned short str_len;
 	char str_dat[FLEX_ARRAY]; /* more */
 };
 
 struct tree_content;
-struct tree_entry
-{
+struct tree_entry {
 	struct tree_content *tree;
 	struct atom_str *name;
-	struct tree_entry_ms
-	{
+	struct tree_entry_ms {
 		uint16_t mode;
 		unsigned char sha1[20];
 	} versions[2];
 };
 
-struct tree_content
-{
+struct tree_content {
 	unsigned int entry_capacity; /* must match avail_tree_content */
 	unsigned int entry_count;
 	unsigned int delta_depth;
 	struct tree_entry *entries[FLEX_ARRAY]; /* more */
 };
 
-struct avail_tree_content
-{
+struct avail_tree_content {
 	unsigned int entry_capacity; /* must match tree_content */
 	struct avail_tree_content *next_avail;
 };
 
-struct branch
-{
+struct branch {
 	struct branch *table_next_branch;
 	struct branch *active_next_branch;
 	const char *name;
@@ -258,16 +247,14 @@ struct branch
 	unsigned char sha1[20];
 };
 
-struct tag
-{
+struct tag {
 	struct tag *next_tag;
 	const char *name;
 	unsigned int pack_id;
 	unsigned char sha1[20];
 };
 
-struct hash_list
-{
+struct hash_list {
 	struct hash_list *next;
 	unsigned char sha1[20];
 };
@@ -278,8 +265,7 @@ typedef enum {
 	WHENSPEC_NOW
 } whenspec_type;
 
-struct recent_command
-{
+struct recent_command {
 	struct recent_command *prev;
 	struct recent_command *next;
 	char *buf;
diff --git a/fetch-pack.h b/fetch-pack.h
index fbe85ac..0608eda 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -1,8 +1,7 @@
 #ifndef FETCH_PACK_H
 #define FETCH_PACK_H
 
-struct fetch_pack_args
-{
+struct fetch_pack_args {
 	const char *uploadpack;
 	int unpacklimit;
 	int depth;
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 75c68d9..3ef4861 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -1,8 +1,7 @@
 #!/bin/sh
 
 echo "/* Automatically generated by $0 */
-struct cmdname_help
-{
+struct cmdname_help {
     char name[16];
     char help[80];
 };
diff --git a/http-push.c b/http-push.c
index ff41a0e..d18346c 100644
--- a/http-push.c
+++ b/http-push.c
@@ -82,8 +82,7 @@ static int helper_status;
 
 static struct object_list *objects;
 
-struct repo
-{
+struct repo {
 	char *url;
 	char *path;
 	int path_len;
@@ -108,8 +107,7 @@ enum transfer_state {
 	COMPLETE
 };
 
-struct transfer_request
-{
+struct transfer_request {
 	struct object *obj;
 	char *url;
 	char *dest;
@@ -127,8 +125,7 @@ struct transfer_request
 
 static struct transfer_request *request_queue_head;
 
-struct xml_ctx
-{
+struct xml_ctx {
 	char *name;
 	int len;
 	char *cdata;
@@ -136,8 +133,7 @@ struct xml_ctx
 	void *userData;
 };
 
-struct remote_lock
-{
+struct remote_lock {
 	char *url;
 	char *owner;
 	char *token;
@@ -156,8 +152,7 @@ struct remote_lock
 /* Flags that remote_ls passes to callback functions */
 #define IS_DIR (1u << 0)
 
-struct remote_ls_ctx
-{
+struct remote_ls_ctx {
 	char *path;
 	void (*userFunc)(struct remote_ls_ctx *ls);
 	void *userData;
diff --git a/http-walker.c b/http-walker.c
index 18bd650..9bc8114 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -3,8 +3,7 @@
 #include "walker.h"
 #include "http.h"
 
-struct alt_base
-{
+struct alt_base {
 	char *base;
 	int got_indices;
 	struct packed_git *packs;
@@ -18,8 +17,7 @@ enum object_request_state {
 	COMPLETE
 };
 
-struct object_request
-{
+struct object_request {
 	struct walker *walker;
 	unsigned char sha1[20];
 	struct alt_base *repo;
diff --git a/http.h b/http.h
index 5c6e243..e9ed3c2 100644
--- a/http.h
+++ b/http.h
@@ -42,14 +42,12 @@
 #define NO_CURL_IOCTL
 #endif
 
-struct slot_results
-{
+struct slot_results {
 	CURLcode curl_result;
 	long http_code;
 };
 
-struct active_request_slot
-{
+struct active_request_slot {
 	CURL *curl;
 	FILE *local;
 	int in_use;
@@ -62,8 +60,7 @@ struct active_request_slot
 	struct active_request_slot *next;
 };
 
-struct buffer
-{
+struct buffer {
 	struct strbuf buf;
 	size_t posn;
 };
@@ -149,8 +146,7 @@ extern int http_fetch_ref(const char *base, struct ref *ref);
 extern int http_get_info_packs(const char *base_url,
 	struct packed_git **packs_head);
 
-struct http_pack_request
-{
+struct http_pack_request {
 	char *url;
 	struct packed_git *target;
 	struct packed_git **lst;
@@ -166,8 +162,7 @@ extern int finish_http_pack_request(struct http_pack_request *preq);
 extern void release_http_pack_request(struct http_pack_request *preq);
 
 /* Helpers for fetching object */
-struct http_object_request
-{
+struct http_object_request {
 	char *url;
 	char tmpfile[PATH_MAX];
 	int localfile;
diff --git a/merge-recursive.c b/merge-recursive.c
index 2a4f739..3debbc4 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -83,10 +83,8 @@ struct rename_df_conflict_info {
  * Since we want to write the index eventually, we cannot reuse the index
  * for these (temporary) data.
  */
-struct stage_data
-{
-	struct
-	{
+struct stage_data {
+	struct {
 		unsigned mode;
 		unsigned char sha[20];
 	} stages[4];
@@ -390,8 +388,7 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
 	}
 }
 
-struct rename
-{
+struct rename {
 	struct diff_filepair *pair;
 	struct stage_data *src_entry;
 	struct stage_data *dst_entry;
@@ -704,8 +701,7 @@ static void update_file(struct merge_options *o,
 
 /* Low level file merging, update and removal */
 
-struct merge_file_info
-{
+struct merge_file_info {
 	unsigned char sha[20];
 	unsigned mode;
 	unsigned clean:1,
diff --git a/pack-check.c b/pack-check.c
index 9d0cb9a..c3bf21d 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -2,8 +2,7 @@
 #include "pack.h"
 #include "pack-revindex.h"
 
-struct idx_entry
-{
+struct idx_entry {
 	off_t                offset;
 	const unsigned char *sha1;
 	unsigned int nr;
diff --git a/string-list.h b/string-list.h
index 4946938..bda6983 100644
--- a/string-list.h
+++ b/string-list.h
@@ -5,8 +5,7 @@ struct string_list_item {
 	char *string;
 	void *util;
 };
-struct string_list
-{
+struct string_list {
 	struct string_list_item *items;
 	unsigned int nr, alloc;
 	unsigned int strdup_strings:1;
diff --git a/transport-helper.c b/transport-helper.c
index ba06b70..0c5b1bd 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -12,8 +12,7 @@
 
 static int debug;
 
-struct helper_data
-{
+struct helper_data {
 	const char *name;
 	struct child_process *helper;
 	FILE *out;
-- 
1.7.4.1

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

* [PATCH 6/8] branch: split off function that writes tracking info and commit subject
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
                     ` (4 preceding siblings ...)
  2011-03-16  7:08   ` [PATCH 5/8] standardize brace placement in struct definitions Jonathan Nieder
@ 2011-03-16  7:10   ` Jonathan Nieder
  2011-03-16  7:12   ` [PATCH 7/8] cherry: split off function to print output lines Jonathan Nieder
  2011-03-16  7:14   ` [PATCH 8/8] diff --submodule: split into bite-sized pieces Jonathan Nieder
  7 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:10 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Lars Hjemli

Introduce a add_verbose_info function that takes care of adding

 - an abbreviated object name;
 - a summary of the form [ahead x, behind y] of the relationship
   to the corresponding upstream branch;
 - a one line commit subject

for the tip commit of a branch, for use in "git branch -v" output.

No functional change intended.  This just unindents the code a little
and makes it easier to skip on first reading.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin/branch.c |   48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index fe8f2fc..b9ba011 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -390,6 +390,30 @@ static int matches_merge_filter(struct commit *commit)
 	return (is_merged == (merge_filter == SHOW_MERGED));
 }
 
+static void add_verbose_info(struct strbuf *out, struct ref_item *item,
+			     int verbose, int abbrev)
+{
+	struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
+	const char *sub = " **** invalid ref ****";
+	struct commit *commit = item->commit;
+
+	if (commit && !parse_commit(commit)) {
+		struct pretty_print_context ctx = {0};
+		pretty_print_commit(CMIT_FMT_ONELINE, commit,
+				    &subject, &ctx);
+		sub = subject.buf;
+	}
+
+	if (item->kind == REF_LOCAL_BRANCH)
+		fill_tracking_info(&stat, item->name, verbose > 1);
+
+	strbuf_addf(out, " %s %s%s",
+		find_unique_abbrev(item->commit->object.sha1, abbrev),
+		stat.buf, sub);
+	strbuf_release(&stat);
+	strbuf_release(&subject);
+}
+
 static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 			   int abbrev, int current, char *prefix)
 {
@@ -430,27 +454,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 
 	if (item->dest)
 		strbuf_addf(&out, " -> %s", item->dest);
-	else if (verbose) {
-		struct strbuf subject = STRBUF_INIT, stat = STRBUF_INIT;
-		const char *sub = " **** invalid ref ****";
-
-		commit = item->commit;
-		if (commit && !parse_commit(commit)) {
-			struct pretty_print_context ctx = {0};
-			pretty_print_commit(CMIT_FMT_ONELINE, commit,
-					    &subject, &ctx);
-			sub = subject.buf;
-		}
-
-		if (item->kind == REF_LOCAL_BRANCH)
-			fill_tracking_info(&stat, item->name, verbose > 1);
-
-		strbuf_addf(&out, " %s %s%s",
-			find_unique_abbrev(item->commit->object.sha1, abbrev),
-			stat.buf, sub);
-		strbuf_release(&stat);
-		strbuf_release(&subject);
-	}
+	else if (verbose)
+		/* " f7c0c00 [ahead 58, behind 197] vcs-svn: drop obj_pool.h" */
+		add_verbose_info(&out, item, verbose, abbrev);
 	printf("%s\n", out.buf);
 	strbuf_release(&name);
 	strbuf_release(&out);
-- 
1.7.4.1

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

* [PATCH 7/8] cherry: split off function to print output lines
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
                     ` (5 preceding siblings ...)
  2011-03-16  7:10   ` [PATCH 6/8] branch: split off function that writes tracking info and commit subject Jonathan Nieder
@ 2011-03-16  7:12   ` Jonathan Nieder
  2011-03-16  7:14   ` [PATCH 8/8] diff --submodule: split into bite-sized pieces Jonathan Nieder
  7 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:12 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, René Scharfe

Readers uninterested in the details of "git cherry"'s output format
can see

	print_commit('-', commit, verbose, abbrev);

and ignore the details.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin/log.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index f5ed690..99e33b3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = {
 	NULL
 };
 
+static void print_commit(char sign, struct commit *commit, int verbose,
+			 int abbrev)
+{
+	if (!verbose) {
+		printf("%c %s\n", sign,
+		       find_unique_abbrev(commit->object.sha1, abbrev));
+	} else {
+		struct strbuf buf = STRBUF_INIT;
+		struct pretty_print_context ctx = {0};
+		pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
+		printf("%c %s %s\n", sign,
+		       find_unique_abbrev(commit->object.sha1, abbrev),
+		       buf.buf);
+		strbuf_release(&buf);
+	}
+}
+
 int cmd_cherry(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info revs;
@@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
 		commit = list->item;
 		if (has_commit_patch_id(commit, &ids))
 			sign = '-';
-
-		if (verbose) {
-			struct strbuf buf = STRBUF_INIT;
-			struct pretty_print_context ctx = {0};
-			pretty_print_commit(CMIT_FMT_ONELINE, commit,
-					    &buf, &ctx);
-			printf("%c %s %s\n", sign,
-			       find_unique_abbrev(commit->object.sha1, abbrev),
-			       buf.buf);
-			strbuf_release(&buf);
-		}
-		else {
-			printf("%c %s\n", sign,
-			       find_unique_abbrev(commit->object.sha1, abbrev));
-		}
-
+		print_commit(sign, commit, verbose, abbrev);
 		list = list->next;
 	}
 
-- 
1.7.4.1

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

* [PATCH 8/8] diff --submodule: split into bite-sized pieces
  2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
                     ` (6 preceding siblings ...)
  2011-03-16  7:12   ` [PATCH 7/8] cherry: split off function to print output lines Jonathan Nieder
@ 2011-03-16  7:14   ` Jonathan Nieder
  2011-03-16 18:43     ` Jens Lehmann
  7 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  7:14 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Johannes Schindelin, Jens Lehmann

Introduce two functions:

 - prepare_submodule_summary prepares the revision walker
   to list changes in a submodule.  That is, it:

   * finds merge bases between the commits pointed to this
     path from before ("left") and after ("right") the change;
   * checks whether this is a fast-forward or fast-backward;
   * prepares a revision walk to list commits in the symmetric
     difference between the commits at each endpoint.

   It returns nonzero on error.

 - print_submodule_summary runs the revision walk and saves
   the result to a strbuf in --left-right format.

The goal is just readability.  No functional change intended.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 submodule.c |  103 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 61 insertions(+), 42 deletions(-)

diff --git a/submodule.c b/submodule.c
index 6f1c107..e9f2b19 100644
--- a/submodule.c
+++ b/submodule.c
@@ -152,17 +152,69 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
 		die("bad --ignore-submodules argument: %s", arg);
 }
 
+static int prepare_submodule_summary(struct rev_info *rev, const char *path,
+		struct commit *left, struct commit *right,
+		int *fast_forward, int *fast_backward)
+{
+	struct commit_list *merge_bases, *list;
+
+	init_revisions(rev, NULL);
+	setup_revisions(0, NULL, rev, NULL);
+	rev->left_right = 1;
+	rev->first_parent_only = 1;
+	left->object.flags |= SYMMETRIC_LEFT;
+	add_pending_object(rev, &left->object, path);
+	add_pending_object(rev, &right->object, path);
+	merge_bases = get_merge_bases(left, right, 1);
+	if (merge_bases) {
+		if (merge_bases->item == left)
+			*fast_forward = 1;
+		else if (merge_bases->item == right)
+			*fast_backward = 1;
+	}
+	for (list = merge_bases; list; list = list->next) {
+		list->item->object.flags |= UNINTERESTING;
+		add_pending_object(rev, &list->item->object,
+			sha1_to_hex(list->item->object.sha1));
+	}
+	return prepare_revision_walk(rev);
+}
+
+static void print_submodule_summary(struct rev_info *rev, FILE *f,
+		const char *del, const char *add, const char *reset)
+{
+	static const char format[] = "  %m %s";
+	struct strbuf sb = STRBUF_INIT;
+	struct commit *commit;
+
+	while ((commit = get_revision(rev))) {
+		struct pretty_print_context ctx = {0};
+		ctx.date_mode = rev->date_mode;
+		strbuf_setlen(&sb, 0);
+		if (commit->object.flags & SYMMETRIC_LEFT) {
+			if (del)
+				strbuf_addstr(&sb, del);
+		}
+		else if (add)
+			strbuf_addstr(&sb, add);
+		format_commit_message(commit, format, &sb, &ctx);
+		if (reset)
+			strbuf_addstr(&sb, reset);
+		strbuf_addch(&sb, '\n');
+		fprintf(f, "%s", sb.buf);
+	}
+	strbuf_release(&sb);
+}
+
 void show_submodule_summary(FILE *f, const char *path,
 		unsigned char one[20], unsigned char two[20],
 		unsigned dirty_submodule,
 		const char *del, const char *add, const char *reset)
 {
 	struct rev_info rev;
-	struct commit *commit, *left = left, *right = right;
-	struct commit_list *merge_bases, *list;
+	struct commit *left = left, *right = right;
 	const char *message = NULL;
 	struct strbuf sb = STRBUF_INIT;
-	static const char *format = "  %m %s";
 	int fast_forward = 0, fast_backward = 0;
 
 	if (is_null_sha1(two))
@@ -175,29 +227,10 @@ void show_submodule_summary(FILE *f, const char *path,
 		 !(right = lookup_commit_reference(two)))
 		message = "(commits not present)";
 
-	if (!message) {
-		init_revisions(&rev, NULL);
-		setup_revisions(0, NULL, &rev, NULL);
-		rev.left_right = 1;
-		rev.first_parent_only = 1;
-		left->object.flags |= SYMMETRIC_LEFT;
-		add_pending_object(&rev, &left->object, path);
-		add_pending_object(&rev, &right->object, path);
-		merge_bases = get_merge_bases(left, right, 1);
-		if (merge_bases) {
-			if (merge_bases->item == left)
-				fast_forward = 1;
-			else if (merge_bases->item == right)
-				fast_backward = 1;
-		}
-		for (list = merge_bases; list; list = list->next) {
-			list->item->object.flags |= UNINTERESTING;
-			add_pending_object(&rev, &list->item->object,
-				sha1_to_hex(list->item->object.sha1));
-		}
-		if (prepare_revision_walk(&rev))
-			message = "(revision walker failed)";
-	}
+	if (!message &&
+	    prepare_submodule_summary(&rev, path, left, right,
+					&fast_forward, &fast_backward))
+		message = "(revision walker failed)";
 
 	if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
 		fprintf(f, "Submodule %s contains untracked content\n", path);
@@ -221,25 +254,11 @@ void show_submodule_summary(FILE *f, const char *path,
 	fwrite(sb.buf, sb.len, 1, f);
 
 	if (!message) {
-		while ((commit = get_revision(&rev))) {
-			struct pretty_print_context ctx = {0};
-			ctx.date_mode = rev.date_mode;
-			strbuf_setlen(&sb, 0);
-			if (commit->object.flags & SYMMETRIC_LEFT) {
-				if (del)
-					strbuf_addstr(&sb, del);
-			}
-			else if (add)
-				strbuf_addstr(&sb, add);
-			format_commit_message(commit, format, &sb, &ctx);
-			if (reset)
-				strbuf_addstr(&sb, reset);
-			strbuf_addch(&sb, '\n');
-			fprintf(f, "%s", sb.buf);
-		}
+		print_submodule_summary(&rev, f, del, add, reset);
 		clear_commit_marks(left, ~0);
 		clear_commit_marks(right, ~0);
 	}
+
 	strbuf_release(&sb);
 }
 
-- 
1.7.4.1

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
  2011-03-16  6:28   ` Jonathan Nieder
@ 2011-03-16  9:09   ` Johannes Sixt
  2011-03-16  9:47     ` Jonathan Nieder
  1 sibling, 1 reply; 34+ messages in thread
From: Johannes Sixt @ 2011-03-16  9:09 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Jonathan Nieder, git, Jeff King

Am 3/16/2011 6:22, schrieb Junio C Hamano:
> I am not suggesting to work this around on the caller side, but I wonder
> what effect the usual workaround to tell the compiler that we know it
> doesn't understand the validity of this variable by saying:
> 
> 	unsigned long expire = expire;
> 
> have on this?

Well, perhaps the compiler followed the C standard more closely than it is
good? By the law, the assignment above provokes undefined behavior, and
the compiler is allowed to do anything.

I think it's time that you accept patches that turn this into

	unsigned long expire = 0;

-- Hannes

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

* Re: [PATCH 2/8] compat: make gcc bswap an inline function
  2011-03-16  7:00   ` [PATCH 2/8] compat: make gcc bswap an inline function Jonathan Nieder
@ 2011-03-16  9:21     ` Johannes Sixt
  2011-03-16  9:31       ` Jonathan Nieder
  0 siblings, 1 reply; 34+ messages in thread
From: Johannes Sixt @ 2011-03-16  9:21 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Junio C Hamano, Nicolas Pitre

Am 3/16/2011 8:00, schrieb Jonathan Nieder:
> +static inline uint32_t git_bswap32(uint32_t x)
> +{
> +	uint32_t result;
> +	if (__builtin_constant_p(x))

Can this predicate ever be true? Isn't it false even if the function is
inlined?

> +		result = default_swab32(x);
> +	else
> +		__asm__("bswap %0" : "=r" (result) : "0" (x));
> +	return result;
> +}

-- Hannes

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

* Re: [PATCH 2/8] compat: make gcc bswap an inline function
  2011-03-16  9:21     ` Johannes Sixt
@ 2011-03-16  9:31       ` Jonathan Nieder
  2011-03-16 19:44         ` Junio C Hamano
  0 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  9:31 UTC (permalink / raw
  To: Johannes Sixt; +Cc: git, Junio C Hamano, Nicolas Pitre

Johannes Sixt wrote:
> Am 3/16/2011 8:00, schrieb Jonathan Nieder:

>> +static inline uint32_t git_bswap32(uint32_t x)
>> +{
>> +	uint32_t result;
>> +	if (__builtin_constant_p(x))
>
> Can this predicate ever be true? Isn't it false even if the function is
> inlined?

It's true if x is a constant.

$ cat test.c
#if 0
gcc -Wall -W -O -o tryit "$0"
exec ./tryit
#else
#include <stdio.h>
#include <stdint.h>

#ifdef __GNUC__
static inline int constant(uint32_t x)
{
	return __builtin_constant_p(x);
}
#else
static inline int constant(uint32_t x) { return 0; }
#endif

int main(void)
{
	printf("%d\n", constant(3 + 5));
	return 0;
}
#endif
$ ./test.c
1

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  9:09   ` Johannes Sixt
@ 2011-03-16  9:47     ` Jonathan Nieder
  2011-03-16  9:54       ` Johannes Sixt
  0 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16  9:47 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Johannes Sixt wrote:

> 	unsigned long expire = 0;

The main downside is that that prevents valgrind from discovering when
the variable really is used uninitialized.  But I do agree that

	unsigned long expire = expire;

is ugly, which is part of why I did not use the latter workaround in
this patch.

Since the makefile already controls what options are passed to msvc,
is there some simple way to suppress the warning from "expire =
expire"?  If not, I would find it tempting to make this and similar
examples look like "unsigned long expire;", treat the warning as
evidence that either

 - the code is too complicated or does not give sufficient hints
   to the compiler about control flow, or
 - the compiler has a bug

and use -Wno-uninitialized for -Werror builds.

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  9:47     ` Jonathan Nieder
@ 2011-03-16  9:54       ` Johannes Sixt
  2011-03-16 10:57         ` Jonathan Nieder
  0 siblings, 1 reply; 34+ messages in thread
From: Johannes Sixt @ 2011-03-16  9:54 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: Junio C Hamano, git, Jeff King

Am 3/16/2011 10:47, schrieb Jonathan Nieder:
> Since the makefile already controls what options are passed to msvc,
> is there some simple way to suppress the warning from "expire =
> expire"?

I don't think so. This is not a special warning, but just

	warning C4700: uninitialized local variable 'expire' used

That is, if you disable it, you also disable it for locations where the
warning would be justified. That's not something that I would like to do.

-- Hannes

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

* Re: [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning
  2011-03-16  9:54       ` Johannes Sixt
@ 2011-03-16 10:57         ` Jonathan Nieder
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
  0 siblings, 1 reply; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 10:57 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Johannes Sixt wrote:

> I don't think so. This is not a special warning, but just
>
> 	warning C4700: uninitialized local variable 'expire' used
>
> That is, if you disable it, you also disable it for locations where the
> warning would be justified. That's not something that I would like to do.

Right.  Below is a patch to play with which gets rid of the
'expire = expire' style suppressions.

It was produced with

	spatch -sp_file self-assignment.cocci $(git ls-files -- '*.c' '*.h')

where self-assignment.cocci is

	@@
	identifier x;
	type T;
	@@

	- T x = x;
	+ T x;

but required some pre- and post-processing to work around coccinelle
bugs. :/
---
 builtin/cat-file.c                     |    2 +-
 builtin/fast-export.c                  |    2 +-
 builtin/rev-list.c                     |    2 +-
 contrib/examples/builtin-fetch--tool.c |    4 ++--
 fast-import.c                          |    8 ++++----
 match-trees.c                          |   12 ++++++------
 merge-recursive.c                      |    2 +-
 run-command.c                          |    2 +-
 submodule.c                            |    2 +-
 transport.c                            |    2 +-
 wt-status.c                            |    2 +-
 11 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 94632db..31cb172 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -168,7 +168,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
 	unsigned char sha1[20];
 	enum object_type type = 0;
 	unsigned long size;
-	void *contents = contents;
+	void *contents;
 
 	if (!obj_name)
 	   return 1;
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index daf1945..408156e 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -463,7 +463,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
 	for (i = 0; i < pending->nr; i++) {
 		struct object_array_entry *e = pending->objects + i;
 		unsigned char sha1[20];
-		struct commit *commit = commit;
+		struct commit *commit;
 		char *full_name;
 
 		if (dwim_ref(e->name, strlen(e->name), sha1, &full_name) != 1)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ba27d39..96d10b0 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -397,7 +397,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 		mark_edges_uninteresting(revs.commits, &revs, show_edge);
 
 	if (bisect_list) {
-		int reaches = reaches, all = all;
+		int reaches, all;
 
 		revs.commits = find_bisection(revs.commits, &reaches, &all,
 					      bisect_find_all);
diff --git a/contrib/examples/builtin-fetch--tool.c b/contrib/examples/builtin-fetch--tool.c
index 3140e40..c5bd034 100644
--- a/contrib/examples/builtin-fetch--tool.c
+++ b/contrib/examples/builtin-fetch--tool.c
@@ -416,14 +416,14 @@ static int expand_refs_wildcard(const char *ls_remote_result, int numrefs,
 static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_result)
 {
 	int err = 0;
-	int lrr_count = lrr_count, i, pass;
+	int lrr_count, i, pass;
 	const char *cp;
 	struct lrr {
 		const char *line;
 		const char *name;
 		int namelen;
 		int shown;
-	} *lrr_list = lrr_list;
+	} *lrr_list;
 
 	for (pass = 0; pass < 2; pass++) {
 		/* pass 0 counts and allocates, pass 1 fills... */
diff --git a/fast-import.c b/fast-import.c
index e24ee2c..565d895 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2196,7 +2196,7 @@ static void file_change_m(struct branch *b)
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
 	const char *endp;
-	struct object_entry *oe = oe;
+	struct object_entry *oe;
 	unsigned char sha1[20];
 	uint16_t mode, inline_data = 0;
 
@@ -2365,7 +2365,7 @@ static void note_change_n(struct branch *b, unsigned char old_fanout)
 {
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
-	struct object_entry *oe = oe;
+	struct object_entry *oe;
 	struct branch *s;
 	unsigned char sha1[20], commit_sha1[20];
 	char path[60];
@@ -2525,7 +2525,7 @@ static int parse_from(struct branch *b)
 
 static struct hash_list *parse_merge(unsigned int *count)
 {
-	struct hash_list *list = NULL, *n, *e = e;
+	struct hash_list *list = NULL, *n, *e;
 	const char *from;
 	struct branch *s;
 
@@ -2819,7 +2819,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20])
 static void parse_cat_blob(void)
 {
 	const char *p;
-	struct object_entry *oe = oe;
+	struct object_entry *oe;
 	unsigned char sha1[20];
 
 	/* cat-blob SP <object> LF */
diff --git a/match-trees.c b/match-trees.c
index 26f7ed1..9cfcc8b 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -72,12 +72,12 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
 		die("%s is not a tree", sha1_to_hex(hash2));
 	init_tree_desc(&two, two_buf, size);
 	while (one.size | two.size) {
-		const unsigned char *elem1 = elem1;
-		const unsigned char *elem2 = elem2;
-		const char *path1 = path1;
-		const char *path2 = path2;
-		unsigned mode1 = mode1;
-		unsigned mode2 = mode2;
+		const unsigned char *elem1;
+		const unsigned char *elem2;
+		const char *path1;
+		const char *path2;
+		unsigned mode1;
+		unsigned mode2;
 		int cmp;
 
 		if (one.size)
diff --git a/merge-recursive.c b/merge-recursive.c
index 2a4f739..8ed0f29 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1583,7 +1583,7 @@ int merge_recursive(struct merge_options *o,
 {
 	struct commit_list *iter;
 	struct commit *merged_common_ancestors;
-	struct tree *mrtree = mrtree;
+	struct tree *mrtree;
 	int clean;
 
 	if (show(o, 4)) {
diff --git a/run-command.c b/run-command.c
index f91e446..f4fb936 100644
--- a/run-command.c
+++ b/run-command.c
@@ -139,7 +139,7 @@ int start_command(struct child_process *cmd)
 {
 	int need_in, need_out, need_err;
 	int fdin[2], fdout[2], fderr[2];
-	int failed_errno = failed_errno;
+	int failed_errno;
 
 	/*
 	 * In case of errors we must keep the promise to close FDs
diff --git a/submodule.c b/submodule.c
index 6f1c107..dcbb2d3 100644
--- a/submodule.c
+++ b/submodule.c
@@ -158,7 +158,7 @@ void show_submodule_summary(FILE *f, const char *path,
 		const char *del, const char *add, const char *reset)
 {
 	struct rev_info rev;
-	struct commit *commit, *left = left, *right = right;
+	struct commit *commit, *left, *right;
 	struct commit_list *merge_bases, *list;
 	const char *message = NULL;
 	struct strbuf sb = STRBUF_INIT;
diff --git a/transport.c b/transport.c
index 0078660..718605f 100644
--- a/transport.c
+++ b/transport.c
@@ -104,7 +104,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
 		return;
 
 	for (;;) {
-		int cmp = cmp, len;
+		int cmp, len;
 
 		if (!fgets(buffer, sizeof(buffer), f)) {
 			fclose(f);
diff --git a/wt-status.c b/wt-status.c
index 4daa8bb..3298897 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -153,7 +153,7 @@ static void wt_status_print_change_data(struct wt_status *s,
 {
 	struct wt_status_change_data *d = it->util;
 	const char *c = color(change_type, s);
-	int status = status;
+	int status;
 	char *one_name;
 	char *two_name;
 	const char *one, *two;
-- 
1.7.4.1

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

* [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick
  2011-03-16 10:57         ` Jonathan Nieder
@ 2011-03-16 11:35           ` Jonathan Nieder
  2011-03-16 11:36             ` [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning Jonathan Nieder
                               ` (5 more replies)
  0 siblings, 6 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:35 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Jonathan Nieder wrote:

> Right.  Below is a patch to play with which gets rid of the
> 'expire = expire' style suppressions.

And here are patches on top to squash the remaining "may be used
uninitialized" warnings (from gcc-4.6 -O2) that they were meant to
address.

The change descriptions are placeholders.  In an ideal world, someone
interested might pick these up and rebase against master
to skip the relevant parts of the above patch altogether.

Jonathan Nieder (6):
  match-trees: kill off remaining -Wuninitialized warning
  run-command: initialize failed_errno to 0
  diff --submodule: suppress -Wuninitialized warning by initializing to
    NULL
  rsync transport: clarify insert_packed_refs
  wt-status: protect against invalid change_type
  fast-import: suppress -Wuninitialized warning by initializing to NULL

 fast-import.c |    2 +-
 match-trees.c |    7 +++++--
 run-command.c |    2 +-
 submodule.c   |    2 +-
 transport.c   |   35 +++++++++++++++++++----------------
 wt-status.c   |    2 ++
 6 files changed, 29 insertions(+), 21 deletions(-)

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

* [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
@ 2011-03-16 11:36             ` Jonathan Nieder
  2011-03-16 11:36             ` [PATCH 2/6] run-command: initialize failed_errno to 0 Jonathan Nieder
                               ` (4 subsequent siblings)
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:36 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Initialize to an invalid value (0, in this case) so we can still
catch bugs as the code evolves.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 match-trees.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/match-trees.c b/match-trees.c
index 9cfcc8b..f325ff5 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -6,6 +6,7 @@ static int score_missing(unsigned mode, const char *path)
 {
 	int score;
 
+	assert(mode);
 	if (S_ISDIR(mode))
 		score = -1000;
 	else if (S_ISLNK(mode))
@@ -19,6 +20,7 @@ static int score_differs(unsigned mode1, unsigned mode2, const char *path)
 {
 	int score;
 
+	assert(mode1 && mode2);
 	if (S_ISDIR(mode1) != S_ISDIR(mode2))
 		score = -100;
 	else if (S_ISLNK(mode1) != S_ISLNK(mode2))
@@ -32,6 +34,8 @@ static int score_matches(unsigned mode1, unsigned mode2, const char *path)
 {
 	int score;
 
+	assert(mode1 && mode2);
+
 	/* Heh, we found SHA-1 collisions between different kind of objects */
 	if (S_ISDIR(mode1) != S_ISDIR(mode2))
 		score = -100;
@@ -76,8 +80,7 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
 		const unsigned char *elem2;
 		const char *path1;
 		const char *path2;
-		unsigned mode1;
-		unsigned mode2;
+		unsigned mode1 = 0, mode2 = 0;
 		int cmp;
 
 		if (one.size)
-- 
1.7.4.1

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

* [PATCH 2/6] run-command: initialize failed_errno to 0
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
  2011-03-16 11:36             ` [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning Jonathan Nieder
@ 2011-03-16 11:36             ` Jonathan Nieder
  2011-03-16 11:37             ` [PATCH 3/6] diff --submodule: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
                               ` (3 subsequent siblings)
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:36 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

It is much better to report "Success" than a seemingly random error
message based on an uninitialized value.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 run-command.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/run-command.c b/run-command.c
index f4fb936..8bb4d62 100644
--- a/run-command.c
+++ b/run-command.c
@@ -139,7 +139,7 @@ int start_command(struct child_process *cmd)
 {
 	int need_in, need_out, need_err;
 	int fdin[2], fdout[2], fderr[2];
-	int failed_errno;
+	int failed_errno = 0;
 
 	/*
 	 * In case of errors we must keep the promise to close FDs
-- 
1.7.4.1

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

* [PATCH 3/6] diff --submodule: suppress -Wuninitialized warning by initializing to NULL
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
  2011-03-16 11:36             ` [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning Jonathan Nieder
  2011-03-16 11:36             ` [PATCH 2/6] run-command: initialize failed_errno to 0 Jonathan Nieder
@ 2011-03-16 11:37             ` Jonathan Nieder
  2011-03-16 11:37             ` [PATCH 4/6] rsync transport: clarify insert_packed_refs Jonathan Nieder
                               ` (2 subsequent siblings)
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:37 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 submodule.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/submodule.c b/submodule.c
index dcbb2d3..a7a7203 100644
--- a/submodule.c
+++ b/submodule.c
@@ -158,7 +158,7 @@ void show_submodule_summary(FILE *f, const char *path,
 		const char *del, const char *add, const char *reset)
 {
 	struct rev_info rev;
-	struct commit *commit, *left, *right;
+	struct commit *commit, *left = NULL, *right = NULL;
 	struct commit_list *merge_bases, *list;
 	const char *message = NULL;
 	struct strbuf sb = STRBUF_INIT;
-- 
1.7.4.1

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

* [PATCH 4/6] rsync transport: clarify insert_packed_refs
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
                               ` (2 preceding siblings ...)
  2011-03-16 11:37             ` [PATCH 3/6] diff --submodule: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
@ 2011-03-16 11:37             ` Jonathan Nieder
  2011-03-16 11:37             ` [PATCH 5/6] wt-status: protect against invalid change_type Jonathan Nieder
  2011-03-16 11:38             ` [PATCH 6/6] fast-import: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:37 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

gcc -Wuninitialized warns us that it might be confusing.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 transport.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/transport.c b/transport.c
index 718605f..0f06720 100644
--- a/transport.c
+++ b/transport.c
@@ -104,7 +104,8 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
 		return;
 
 	for (;;) {
-		int cmp, len;
+		int cmp = 1, len;
+		struct ref *next;
 
 		if (!fgets(buffer, sizeof(buffer), f)) {
 			fclose(f);
@@ -118,22 +119,24 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
 			buffer[--len] = '\0';
 		if (len < 41)
 			continue;
-		while ((*list)->next &&
-				(cmp = strcmp(buffer + 41,
-				      (*list)->next->name)) > 0)
-			list = &(*list)->next;
-		if (!(*list)->next || cmp < 0) {
-			struct ref *next = alloc_ref(buffer + 41);
-			buffer[40] = '\0';
-			if (get_sha1_hex(buffer, next->old_sha1)) {
-				warning ("invalid SHA-1: %s", buffer);
-				free(next);
-				continue;
-			}
-			next->next = (*list)->next;
-			(*list)->next = next;
-			list = &(*list)->next;
+		for (; (*list)->next; list = &(*list)->next) {
+			cmp = strcmp(buffer + 41, (*list)->next->name);
+			if (cmp <= 0)
+				break;
+		}
+		if (!cmp)	/* already inserted. */
+			continue;
+
+		next = alloc_ref(buffer + 41);
+		buffer[40] = '\0';
+		if (get_sha1_hex(buffer, next->old_sha1)) {
+			warning ("invalid SHA-1: %s", buffer);
+			free(next);
+			continue;
 		}
+		next->next = (*list)->next;
+		(*list)->next = next;
+		list = &(*list)->next;
 	}
 }
 
-- 
1.7.4.1

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

* [PATCH 5/6] wt-status: protect against invalid change_type
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
                               ` (3 preceding siblings ...)
  2011-03-16 11:37             ` [PATCH 4/6] rsync transport: clarify insert_packed_refs Jonathan Nieder
@ 2011-03-16 11:37             ` Jonathan Nieder
  2011-03-16 11:38             ` [PATCH 6/6] fast-import: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:37 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Noticed with gcc -Wuninitialized.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 wt-status.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 3298897..25a411b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -181,6 +181,8 @@ static void wt_status_print_change_data(struct wt_status *s,
 		}
 		status = d->worktree_status;
 		break;
+	default:
+		die("BUG: invalid change_type");
 	}
 
 	one = quote_path(one_name, -1, &onebuf, s->prefix);
-- 
1.7.4.1

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

* [PATCH 6/6] fast-import: suppress -Wuninitialized warning by initializing to NULL
  2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
                               ` (4 preceding siblings ...)
  2011-03-16 11:37             ` [PATCH 5/6] wt-status: protect against invalid change_type Jonathan Nieder
@ 2011-03-16 11:38             ` Jonathan Nieder
  5 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 11:38 UTC (permalink / raw
  To: Johannes Sixt; +Cc: Junio C Hamano, git, Jeff King

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
That's the end. :)

Good night.

 fast-import.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 565d895..75405af 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2196,7 +2196,7 @@ static void file_change_m(struct branch *b)
 	const char *p = command_buf.buf + 2;
 	static struct strbuf uq = STRBUF_INIT;
 	const char *endp;
-	struct object_entry *oe;
+	struct object_entry *oe = NULL;
 	unsigned char sha1[20];
 	uint16_t mode, inline_data = 0;
 
-- 
1.7.4.1

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

* Re: [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned
  2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
  2011-03-16  5:38   ` Junio C Hamano
@ 2011-03-16 14:20   ` Nguyen Thai Ngoc Duy
  1 sibling, 0 replies; 34+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-03-16 14:20 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Junio C Hamano

2011/3/16 Jonathan Nieder <jrnieder@gmail.com>:
> As "gcc -pedantic" notices, a two's complement 1-bit signed integer
> cannot represent the value '1'.
>
>  dir.c: In function 'init_pathspec':
>  dir.c:1291:4: warning: overflow in implicit constant conversion [-Woverflow]

Thanks. I think I was aware of this but neglected because they are
used as booleans, 1 or -1 does not matter. Good fix anyway.
-- 
Duy

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

* Re: [PATCH 8/8] diff --submodule: split into bite-sized pieces
  2011-03-16  7:14   ` [PATCH 8/8] diff --submodule: split into bite-sized pieces Jonathan Nieder
@ 2011-03-16 18:43     ` Jens Lehmann
  2011-03-16 19:33       ` Jonathan Nieder
  0 siblings, 1 reply; 34+ messages in thread
From: Jens Lehmann @ 2011-03-16 18:43 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Junio C Hamano, Johannes Schindelin

Am 16.03.2011 08:14, schrieb Jonathan Nieder:
> Introduce two functions:
> 
>  - prepare_submodule_summary prepares the revision walker
>    to list changes in a submodule.  That is, it:
> 
>    * finds merge bases between the commits pointed to this
>      path from before ("left") and after ("right") the change;
>    * checks whether this is a fast-forward or fast-backward;
>    * prepares a revision walk to list commits in the symmetric
>      difference between the commits at each endpoint.
> 
>    It returns nonzero on error.
> 
>  - print_submodule_summary runs the revision walk and saves
>    the result to a strbuf in --left-right format.
> 
> The goal is just readability.  No functional change intended.

Ack, looks good and makes sense to me.


> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  submodule.c |  103 +++++++++++++++++++++++++++++++++++------------------------
>  1 files changed, 61 insertions(+), 42 deletions(-)
> 
> diff --git a/submodule.c b/submodule.c
> index 6f1c107..e9f2b19 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -152,17 +152,69 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,
>  		die("bad --ignore-submodules argument: %s", arg);
>  }
>  
> +static int prepare_submodule_summary(struct rev_info *rev, const char *path,
> +		struct commit *left, struct commit *right,
> +		int *fast_forward, int *fast_backward)
> +{
> +	struct commit_list *merge_bases, *list;
> +
> +	init_revisions(rev, NULL);
> +	setup_revisions(0, NULL, rev, NULL);
> +	rev->left_right = 1;
> +	rev->first_parent_only = 1;
> +	left->object.flags |= SYMMETRIC_LEFT;
> +	add_pending_object(rev, &left->object, path);
> +	add_pending_object(rev, &right->object, path);
> +	merge_bases = get_merge_bases(left, right, 1);
> +	if (merge_bases) {
> +		if (merge_bases->item == left)
> +			*fast_forward = 1;
> +		else if (merge_bases->item == right)
> +			*fast_backward = 1;
> +	}
> +	for (list = merge_bases; list; list = list->next) {
> +		list->item->object.flags |= UNINTERESTING;
> +		add_pending_object(rev, &list->item->object,
> +			sha1_to_hex(list->item->object.sha1));
> +	}
> +	return prepare_revision_walk(rev);
> +}
> +
> +static void print_submodule_summary(struct rev_info *rev, FILE *f,
> +		const char *del, const char *add, const char *reset)
> +{
> +	static const char format[] = "  %m %s";
> +	struct strbuf sb = STRBUF_INIT;
> +	struct commit *commit;
> +
> +	while ((commit = get_revision(rev))) {
> +		struct pretty_print_context ctx = {0};
> +		ctx.date_mode = rev->date_mode;
> +		strbuf_setlen(&sb, 0);
> +		if (commit->object.flags & SYMMETRIC_LEFT) {
> +			if (del)
> +				strbuf_addstr(&sb, del);
> +		}
> +		else if (add)
> +			strbuf_addstr(&sb, add);
> +		format_commit_message(commit, format, &sb, &ctx);
> +		if (reset)
> +			strbuf_addstr(&sb, reset);
> +		strbuf_addch(&sb, '\n');
> +		fprintf(f, "%s", sb.buf);
> +	}
> +	strbuf_release(&sb);
> +}
> +
>  void show_submodule_summary(FILE *f, const char *path,
>  		unsigned char one[20], unsigned char two[20],
>  		unsigned dirty_submodule,
>  		const char *del, const char *add, const char *reset)
>  {
>  	struct rev_info rev;
> -	struct commit *commit, *left = left, *right = right;
> -	struct commit_list *merge_bases, *list;
> +	struct commit *left = left, *right = right;
>  	const char *message = NULL;
>  	struct strbuf sb = STRBUF_INIT;
> -	static const char *format = "  %m %s";
>  	int fast_forward = 0, fast_backward = 0;
>  
>  	if (is_null_sha1(two))
> @@ -175,29 +227,10 @@ void show_submodule_summary(FILE *f, const char *path,
>  		 !(right = lookup_commit_reference(two)))
>  		message = "(commits not present)";
>  
> -	if (!message) {
> -		init_revisions(&rev, NULL);
> -		setup_revisions(0, NULL, &rev, NULL);
> -		rev.left_right = 1;
> -		rev.first_parent_only = 1;
> -		left->object.flags |= SYMMETRIC_LEFT;
> -		add_pending_object(&rev, &left->object, path);
> -		add_pending_object(&rev, &right->object, path);
> -		merge_bases = get_merge_bases(left, right, 1);
> -		if (merge_bases) {
> -			if (merge_bases->item == left)
> -				fast_forward = 1;
> -			else if (merge_bases->item == right)
> -				fast_backward = 1;
> -		}
> -		for (list = merge_bases; list; list = list->next) {
> -			list->item->object.flags |= UNINTERESTING;
> -			add_pending_object(&rev, &list->item->object,
> -				sha1_to_hex(list->item->object.sha1));
> -		}
> -		if (prepare_revision_walk(&rev))
> -			message = "(revision walker failed)";
> -	}
> +	if (!message &&
> +	    prepare_submodule_summary(&rev, path, left, right,
> +					&fast_forward, &fast_backward))
> +		message = "(revision walker failed)";
>  
>  	if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
>  		fprintf(f, "Submodule %s contains untracked content\n", path);
> @@ -221,25 +254,11 @@ void show_submodule_summary(FILE *f, const char *path,
>  	fwrite(sb.buf, sb.len, 1, f);
>  
>  	if (!message) {
> -		while ((commit = get_revision(&rev))) {
> -			struct pretty_print_context ctx = {0};
> -			ctx.date_mode = rev.date_mode;
> -			strbuf_setlen(&sb, 0);
> -			if (commit->object.flags & SYMMETRIC_LEFT) {
> -				if (del)
> -					strbuf_addstr(&sb, del);
> -			}
> -			else if (add)
> -				strbuf_addstr(&sb, add);
> -			format_commit_message(commit, format, &sb, &ctx);
> -			if (reset)
> -				strbuf_addstr(&sb, reset);
> -			strbuf_addch(&sb, '\n');
> -			fprintf(f, "%s", sb.buf);
> -		}
> +		print_submodule_summary(&rev, f, del, add, reset);
>  		clear_commit_marks(left, ~0);
>  		clear_commit_marks(right, ~0);
>  	}
> +
>  	strbuf_release(&sb);
>  }
>  

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

* Re: [PATCH 8/8] diff --submodule: split into bite-sized pieces
  2011-03-16 18:43     ` Jens Lehmann
@ 2011-03-16 19:33       ` Jonathan Nieder
  0 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 19:33 UTC (permalink / raw
  To: Jens Lehmann; +Cc: git, Junio C Hamano, Johannes Schindelin

Jens Lehmann wrote:
> Am 16.03.2011 08:14, schrieb Jonathan Nieder:

>> Introduce two functions:
>> 
>>  - prepare_submodule_summary prepares the revision walker
>>    to list changes in a submodule.  That is, it:
>> 
>>    * finds merge bases between the commits pointed to this
>>      path from before ("left") and after ("right") the change;

pointed to at this path before [missing "at", spurious "from"]

>>    * checks whether this is a fast-forward or fast-backward;
>>    * prepares a revision walk to list commits in the symmetric
>>      difference between the commits at each endpoint.
>>
>>    It returns nonzero on error.
>>
>>  - print_submodule_summary runs the revision walk and saves
>>    the result to a strbuf in --left-right format.

runs the revision walk and prints the result in --left-right format
[the strbuf is an implementation detail; not sure how it snuck into
the commit message]

>> The goal is just readability.  No functional change intended.
>
> Ack, looks good and makes sense to me.

Thanks, Jens.  Looking back over the commit message I see I left in
some typos but the patch still looks good to me fwiw.

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

* Re: [PATCH 2/8] compat: make gcc bswap an inline function
  2011-03-16  9:31       ` Jonathan Nieder
@ 2011-03-16 19:44         ` Junio C Hamano
  0 siblings, 0 replies; 34+ messages in thread
From: Junio C Hamano @ 2011-03-16 19:44 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: Johannes Sixt, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Johannes Sixt wrote:
>> Am 3/16/2011 8:00, schrieb Jonathan Nieder:
>
>>> +static inline uint32_t git_bswap32(uint32_t x)
>>> +{
>>> +	uint32_t result;
>>> +	if (__builtin_constant_p(x))
>>
>> Can this predicate ever be true? Isn't it false even if the function is
>> inlined?
>
> It's true if x is a constant.
> ... demonstration ...

And this trivial function:

    int f(void) {
            return git_bswap32(0x01000000);
    }

compiles down to:

    .globl f
            .type   f, @function
    f:
    .LFB2:
            .cfi_startproc
            movl    $1, %eax
            ret
            .cfi_endproc

on my amd64, with -Os, -O1, or -O2 (gcc 4.4.5). Of course -O0 gives a true
call to git_bswap32() and leaves the definitions of two helper functions
in the object, but that is to be expected.

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

* Re: [PATCH 4/8] vcs-svn: remove spurious semicolons
  2011-03-16  7:02   ` [PATCH 4/8] vcs-svn: remove spurious semicolons Jonathan Nieder
@ 2011-03-16 19:47     ` Junio C Hamano
  2011-03-16 20:03       ` Jonathan Nieder
  0 siblings, 1 reply; 34+ messages in thread
From: Junio C Hamano @ 2011-03-16 19:47 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Ramkumar Ramachandra

Jonathan Nieder <jrnieder@gmail.com> writes:

> trp_gen is not a statement or function call, so it should not be
> followed with a semicolon.  Noticed by gcc -pedantic.
>
>  vcs-svn/repo_tree.c:41:81: warning: ISO C does not allow extra ';'
>   outside of a function [-pedantic]
> ...
> diff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c
> index 491f013..207ffc3 100644
> --- a/vcs-svn/repo_tree.c
> +++ b/vcs-svn/repo_tree.c
> @@ -38,7 +38,7 @@ static uint32_t mark;
>  static int repo_dirent_name_cmp(const void *a, const void *b);
>  
>  /* Treap for directory entries */
> -trp_gen(static, dent_, struct repo_dirent, children, dent, repo_dirent_name_cmp);
> +trp_gen(static, dent_, struct repo_dirent, children, dent, repo_dirent_name_cmp)

Yuck.  Correct but ugly.

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

* Re: [PATCH 4/8] vcs-svn: remove spurious semicolons
  2011-03-16 19:47     ` Junio C Hamano
@ 2011-03-16 20:03       ` Jonathan Nieder
  0 siblings, 0 replies; 34+ messages in thread
From: Jonathan Nieder @ 2011-03-16 20:03 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, Ramkumar Ramachandra

Junio C Hamano wrote:

> Yuck.  Correct but ugly.

Yes, might be better for me to just hurry and apply David's patches to
get rid of the treap. :)

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

* Re: [PATCH 5/8] standardize brace placement in struct definitions
  2011-03-16  7:08   ` [PATCH 5/8] standardize brace placement in struct definitions Jonathan Nieder
@ 2011-03-18  7:25     ` Junio C Hamano
  0 siblings, 0 replies; 34+ messages in thread
From: Junio C Hamano @ 2011-03-18  7:25 UTC (permalink / raw
  To: Jonathan Nieder; +Cc: git, Shawn O. Pearce

Jonathan Nieder <jrnieder@gmail.com> writes:

> In a struct definitions, unlike functions, the prevailing style is for
> the opening brace to go on the same line as the struct name, like so:
>
>  struct foo {
> 	int bar;
> 	char *baz;
>  };

Thanks for killing these eyesores.

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

end of thread, other threads:[~2011-03-18  7:25 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16  2:49 [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Jonathan Nieder
2011-03-16  3:42 ` [PATCH nd/struct-pathspec] declare 1-bit bitfields to be unsigned Jonathan Nieder
2011-03-16  5:38   ` Junio C Hamano
2011-03-16 14:20   ` Nguyen Thai Ngoc Duy
2011-03-16  5:22 ` [PATCH/RFC] reflog: silence -O3 -Wuninitialized warning Junio C Hamano
2011-03-16  6:28   ` Jonathan Nieder
2011-03-16  9:09   ` Johannes Sixt
2011-03-16  9:47     ` Jonathan Nieder
2011-03-16  9:54       ` Johannes Sixt
2011-03-16 10:57         ` Jonathan Nieder
2011-03-16 11:35           ` [RFC/PATCH 0/6] silence -Wuninitialized warnings that previously used the a = a trick Jonathan Nieder
2011-03-16 11:36             ` [PATCH 1/6] match-trees: kill off remaining -Wuninitialized warning Jonathan Nieder
2011-03-16 11:36             ` [PATCH 2/6] run-command: initialize failed_errno to 0 Jonathan Nieder
2011-03-16 11:37             ` [PATCH 3/6] diff --submodule: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
2011-03-16 11:37             ` [PATCH 4/6] rsync transport: clarify insert_packed_refs Jonathan Nieder
2011-03-16 11:37             ` [PATCH 5/6] wt-status: protect against invalid change_type Jonathan Nieder
2011-03-16 11:38             ` [PATCH 6/6] fast-import: suppress -Wuninitialized warning by initializing to NULL Jonathan Nieder
2011-03-16  6:53 ` [PATCH 0/8] more warnings and cleanups Jonathan Nieder
2011-03-16  6:59   ` [PATCH 1/8] enums: omit trailing comma for portability Jonathan Nieder
2011-03-16  7:00   ` [PATCH 2/8] compat: make gcc bswap an inline function Jonathan Nieder
2011-03-16  9:21     ` Johannes Sixt
2011-03-16  9:31       ` Jonathan Nieder
2011-03-16 19:44         ` Junio C Hamano
2011-03-16  7:01   ` [PATCH 3/8] svn-fe: do not use "return" for tail call returning void Jonathan Nieder
2011-03-16  7:02   ` [PATCH 4/8] vcs-svn: remove spurious semicolons Jonathan Nieder
2011-03-16 19:47     ` Junio C Hamano
2011-03-16 20:03       ` Jonathan Nieder
2011-03-16  7:08   ` [PATCH 5/8] standardize brace placement in struct definitions Jonathan Nieder
2011-03-18  7:25     ` Junio C Hamano
2011-03-16  7:10   ` [PATCH 6/8] branch: split off function that writes tracking info and commit subject Jonathan Nieder
2011-03-16  7:12   ` [PATCH 7/8] cherry: split off function to print output lines Jonathan Nieder
2011-03-16  7:14   ` [PATCH 8/8] diff --submodule: split into bite-sized pieces Jonathan Nieder
2011-03-16 18:43     ` Jens Lehmann
2011-03-16 19:33       ` Jonathan Nieder

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).