git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] Trivial patches
@ 2013-05-30 13:56 Felipe Contreras
  2013-05-30 13:56 ` [PATCH 1/4] read-cache: fix wrong 'the_index' usage Felipe Contreras
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Felipe Contreras @ 2013-05-30 13:56 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

Hi,

Here's a bunch of  trivial patches, mostly syle, but the first one might be
important.

Felipe Contreras (4):
  read-cache: fix wrong 'the_index' usage
  read-cache: trivial style cleanups
  unpack-trees: trivial cleanup
  sha1_file: trivial style cleanup

 read-cache.c   | 6 +++---
 sha1_file.c    | 2 +-
 unpack-trees.c | 3 +--
 3 files changed, 5 insertions(+), 6 deletions(-)

-- 
1.8.3.rc3.312.g47657de

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

* [PATCH 1/4] read-cache: fix wrong 'the_index' usage
  2013-05-30 13:56 [PATCH 0/4] Trivial patches Felipe Contreras
@ 2013-05-30 13:56 ` Felipe Contreras
  2013-06-03 17:09   ` Junio C Hamano
  2013-05-30 13:56 ` [PATCH 2/4] read-cache: trivial style cleanups Felipe Contreras
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Felipe Contreras @ 2013-05-30 13:56 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

We are dealing with the 'istate' index, not 'the_index'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/read-cache.c b/read-cache.c
index 04ed561..5253ec5 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -626,7 +626,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 			if (*ptr == '/') {
 				struct cache_entry *foundce;
 				++ptr;
-				foundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case);
+				foundce = index_name_exists(istate, ce->name, ptr - ce->name, ignore_case);
 				if (foundce) {
 					memcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr);
 					startPtr = ptr;
-- 
1.8.3.rc3.312.g47657de

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

* [PATCH 2/4] read-cache: trivial style cleanups
  2013-05-30 13:56 [PATCH 0/4] Trivial patches Felipe Contreras
  2013-05-30 13:56 ` [PATCH 1/4] read-cache: fix wrong 'the_index' usage Felipe Contreras
@ 2013-05-30 13:56 ` Felipe Contreras
  2013-05-30 13:56 ` [PATCH 3/4] unpack-trees: trivial cleanup Felipe Contreras
  2013-05-30 13:56 ` [PATCH 4/4] sha1_file: trivial style cleanup Felipe Contreras
  3 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2013-05-30 13:56 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 read-cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 5253ec5..7040e79 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -979,7 +979,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
 	if (istate->cache_nr == istate->cache_alloc) {
 		istate->cache_alloc = alloc_nr(istate->cache_alloc);
 		istate->cache = xrealloc(istate->cache,
-					istate->cache_alloc * sizeof(struct cache_entry *));
+					istate->cache_alloc * sizeof(*istate->cache));
 	}
 
 	/* Add it in.. */
@@ -1449,7 +1449,7 @@ int read_index_from(struct index_state *istate, const char *path)
 	istate->version = ntohl(hdr->hdr_version);
 	istate->cache_nr = ntohl(hdr->hdr_entries);
 	istate->cache_alloc = alloc_nr(istate->cache_nr);
-	istate->cache = xcalloc(istate->cache_alloc, sizeof(struct cache_entry *));
+	istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));
 	istate->initialized = 1;
 
 	if (istate->version == 4)
-- 
1.8.3.rc3.312.g47657de

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

* [PATCH 3/4] unpack-trees: trivial cleanup
  2013-05-30 13:56 [PATCH 0/4] Trivial patches Felipe Contreras
  2013-05-30 13:56 ` [PATCH 1/4] read-cache: fix wrong 'the_index' usage Felipe Contreras
  2013-05-30 13:56 ` [PATCH 2/4] read-cache: trivial style cleanups Felipe Contreras
@ 2013-05-30 13:56 ` Felipe Contreras
  2013-06-03 17:13   ` Junio C Hamano
  2013-05-30 13:56 ` [PATCH 4/4] sha1_file: trivial style cleanup Felipe Contreras
  3 siblings, 1 reply; 8+ messages in thread
From: Felipe Contreras @ 2013-05-30 13:56 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

dfc has not been initialized at this point.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 unpack-trees.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index ede4299..36f4ff7 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 	if (!o->skip_sparse_checkout)
 		mark_new_skip_worktree(o->el, o->src_index, 0, CE_NEW_SKIP_WORKTREE);
 
-	if (!dfc)
-		dfc = xcalloc(1, cache_entry_size(0));
+	dfc = xcalloc(1, cache_entry_size(0));
 	o->df_conflict_entry = dfc;
 
 	if (len) {
-- 
1.8.3.rc3.312.g47657de

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

* [PATCH 4/4] sha1_file: trivial style cleanup
  2013-05-30 13:56 [PATCH 0/4] Trivial patches Felipe Contreras
                   ` (2 preceding siblings ...)
  2013-05-30 13:56 ` [PATCH 3/4] unpack-trees: trivial cleanup Felipe Contreras
@ 2013-05-30 13:56 ` Felipe Contreras
  3 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2013-05-30 13:56 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 sha1_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sha1_file.c b/sha1_file.c
index 67e815b..b114cc9 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2138,7 +2138,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
 		if (!data)
 			die("failed to apply delta");
 
-		free (delta_data);
+		free(delta_data);
 	}
 
 	*final_type = type;
-- 
1.8.3.rc3.312.g47657de

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

* Re: [PATCH 1/4] read-cache: fix wrong 'the_index' usage
  2013-05-30 13:56 ` [PATCH 1/4] read-cache: fix wrong 'the_index' usage Felipe Contreras
@ 2013-06-03 17:09   ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2013-06-03 17:09 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> We are dealing with the 'istate' index, not 'the_index'.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---

Good catch; will apply.

>  read-cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index 04ed561..5253ec5 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -626,7 +626,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
>  			if (*ptr == '/') {
>  				struct cache_entry *foundce;
>  				++ptr;
> -				foundce = index_name_exists(&the_index, ce->name, ptr - ce->name, ignore_case);
> +				foundce = index_name_exists(istate, ce->name, ptr - ce->name, ignore_case);
>  				if (foundce) {
>  					memcpy((void *)startPtr, foundce->name + (startPtr - ce->name), ptr - startPtr);
>  					startPtr = ptr;

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

* Re: [PATCH 3/4] unpack-trees: trivial cleanup
  2013-05-30 13:56 ` [PATCH 3/4] unpack-trees: trivial cleanup Felipe Contreras
@ 2013-06-03 17:13   ` Junio C Hamano
  2013-06-03 20:51     ` Felipe Contreras
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2013-06-03 17:13 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> dfc has not been initialized at this point.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---

Upon the first entry to this function, because dfc is 

	static struct cache_entry *dfc;

it is NULL.  In that case, we allocate one instance.  When the
function is called again, we can reuse the entry, because it merely
acts as a unique sentinel value.

And we do not free() it.

>  unpack-trees.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index ede4299..36f4ff7 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1040,8 +1040,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
>  	if (!o->skip_sparse_checkout)
>  		mark_new_skip_worktree(o->el, o->src_index, 0, CE_NEW_SKIP_WORKTREE);
>  
> -	if (!dfc)
> -		dfc = xcalloc(1, cache_entry_size(0));
> +	dfc = xcalloc(1, cache_entry_size(0));
>  	o->df_conflict_entry = dfc;
>  
>  	if (len) {

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

* Re: [PATCH 3/4] unpack-trees: trivial cleanup
  2013-06-03 17:13   ` Junio C Hamano
@ 2013-06-03 20:51     ` Felipe Contreras
  0 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2013-06-03 20:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jun 3, 2013 at 12:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> dfc has not been initialized at this point.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>
> Upon the first entry to this function, because dfc is
>
>         static struct cache_entry *dfc;

Ah, I didn't notice it's static. Smells error-prone, but I guess it's
OK for now.

-- 
Felipe Contreras

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

end of thread, other threads:[~2013-06-03 20:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 13:56 [PATCH 0/4] Trivial patches Felipe Contreras
2013-05-30 13:56 ` [PATCH 1/4] read-cache: fix wrong 'the_index' usage Felipe Contreras
2013-06-03 17:09   ` Junio C Hamano
2013-05-30 13:56 ` [PATCH 2/4] read-cache: trivial style cleanups Felipe Contreras
2013-05-30 13:56 ` [PATCH 3/4] unpack-trees: trivial cleanup Felipe Contreras
2013-06-03 17:13   ` Junio C Hamano
2013-06-03 20:51     ` Felipe Contreras
2013-05-30 13:56 ` [PATCH 4/4] sha1_file: trivial style cleanup Felipe Contreras

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