linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
@ 2008-01-04 21:10 Scott Wood
  2008-01-06  3:37 ` David Gibson
  2008-01-07 15:22 ` Jon Loeliger
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Wood @ 2008-01-04 21:10 UTC (permalink / raw)
  To: jdl; +Cc: linuxppc-dev

Also, free file->dir when freeing file.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 srcpos.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/srcpos.c b/srcpos.c
index 7340c33..7a0c47e 100644
--- a/srcpos.c
+++ b/srcpos.c
@@ -86,6 +86,16 @@ struct dtc_file *dtc_open_file(const char *fname,
 		return file;
 	}
 
+	if (fname[0] == '/') {
+		file->file = fopen(fname, "r");
+
+		if (!file->file)
+			goto out;
+
+		file->name = strdup(fname);
+		return file;
+	}
+
 	if (!search)
 		search = &default_search;
 
@@ -100,6 +110,7 @@ struct dtc_file *dtc_open_file(const char *fname,
 	}
 
 out:
+	free((void *)file->dir);
 	free(file);
 	return NULL;
 }
@@ -109,5 +120,6 @@ void dtc_close_file(struct dtc_file *file)
 	if (fclose(file->file))
 		die("Error closing \"%s\": %s\n", file->name, strerror(errno));
 
+	free((void *)file->dir);
 	free(file);
 }
-- 
1.5.3

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

* Re: [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
  2008-01-04 21:10 [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file Scott Wood
@ 2008-01-06  3:37 ` David Gibson
  2008-01-06 22:46   ` Scott Wood
  2008-01-07 15:22 ` Jon Loeliger
  1 sibling, 1 reply; 6+ messages in thread
From: David Gibson @ 2008-01-06  3:37 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, jdl

On Fri, Jan 04, 2008 at 03:10:45PM -0600, Scott Wood wrote:
> Also, free file->dir when freeing file.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
>  srcpos.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/srcpos.c b/srcpos.c
> index 7340c33..7a0c47e 100644
> --- a/srcpos.c
> +++ b/srcpos.c
> @@ -86,6 +86,16 @@ struct dtc_file *dtc_open_file(const char *fname,
>  		return file;
>  	}
>  
> +	if (fname[0] == '/') {
> +		file->file = fopen(fname, "r");
> +
> +		if (!file->file)
> +			goto out;
> +
> +		file->name = strdup(fname);
> +		return file;
> +	}
> +
>  	if (!search)
>  		search = &default_search;
>  
> @@ -100,6 +110,7 @@ struct dtc_file *dtc_open_file(const char *fname,
>  	}
>  
>  out:
> +	free((void *)file->dir);

That cast shouldn't be there.

>  	free(file);
>  	return NULL;
>  }
> @@ -109,5 +120,6 @@ void dtc_close_file(struct dtc_file *file)
>  	if (fclose(file->file))
>  		die("Error closing \"%s\": %s\n", file->name, strerror(errno));
>  
> +	free((void *)file->dir);

Or here.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

* Re: [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
  2008-01-06  3:37 ` David Gibson
@ 2008-01-06 22:46   ` Scott Wood
  2008-01-07 15:25     ` Jon Loeliger
  2008-01-10  5:09     ` David Gibson
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Wood @ 2008-01-06 22:46 UTC (permalink / raw)
  To: jdl, linuxppc-dev

On Sun, Jan 06, 2008 at 02:37:16PM +1100, David Gibson wrote:
> >  out:
> > +	free((void *)file->dir);
> 
> That cast shouldn't be there.

It generates a constness warning otherwise.  I was on the fence over
whether to just remove the constness (even though the data is never
modified during its lifetime); would that be preferable?

-Scott

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

* Re: [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
  2008-01-04 21:10 [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file Scott Wood
  2008-01-06  3:37 ` David Gibson
@ 2008-01-07 15:22 ` Jon Loeliger
  1 sibling, 0 replies; 6+ messages in thread
From: Jon Loeliger @ 2008-01-07 15:22 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

So, like, the other day Scott Wood mumbled:
> Also, free file->dir when freeing file.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>

Applied.

Thanks.

jdl

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

* Re: [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
  2008-01-06 22:46   ` Scott Wood
@ 2008-01-07 15:25     ` Jon Loeliger
  2008-01-10  5:09     ` David Gibson
  1 sibling, 0 replies; 6+ messages in thread
From: Jon Loeliger @ 2008-01-07 15:25 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

So, like, the other day Scott Wood mumbled:
> On Sun, Jan 06, 2008 at 02:37:16PM +1100, David Gibson wrote:
> > >  out:
> > > +	free((void *)file->dir);
> > 
> > That cast shouldn't be there.
> 
> It generates a constness warning otherwise.  I was on the fence over
> whether to just remove the constness (even though the data is never
> modified during its lifetime); would that be preferable?

The earlier patch was applied for functionality reasons.
If needed, a follow-up patch to sort this out is still welcome.

jdl

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

* Re: [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file.
  2008-01-06 22:46   ` Scott Wood
  2008-01-07 15:25     ` Jon Loeliger
@ 2008-01-10  5:09     ` David Gibson
  1 sibling, 0 replies; 6+ messages in thread
From: David Gibson @ 2008-01-10  5:09 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, jdl

On Sun, Jan 06, 2008 at 04:46:24PM -0600, Scott Wood wrote:
> On Sun, Jan 06, 2008 at 02:37:16PM +1100, David Gibson wrote:
> > >  out:
> > > +	free((void *)file->dir);
> > 
> > That cast shouldn't be there.
> 
> It generates a constness warning otherwise.  I was on the fence over
> whether to just remove the constness (even though the data is never
> modified during its lifetime); would that be preferable?

I think that is preferable.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

end of thread, other threads:[~2008-01-10  5:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-04 21:10 [PATCH 2/3] Handle absolute pathnames correctly in dtc_open_file Scott Wood
2008-01-06  3:37 ` David Gibson
2008-01-06 22:46   ` Scott Wood
2008-01-07 15:25     ` Jon Loeliger
2008-01-10  5:09     ` David Gibson
2008-01-07 15:22 ` Jon Loeliger

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