Message ID | 20170912123554.7388-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | tmpdir: fix asprintf return value check | expand |
On 12/09/2017 14:35, Christian Storm wrote: > Fix travis's complaint about missing asprintf > return value check (-Wunused-result). > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > core/util.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/core/util.c b/core/util.c > index 8c6b295..821b6df 100644 > --- a/core/util.c > +++ b/core/util.c > @@ -71,7 +71,9 @@ const char* get_tmpdir(void) > return TMPDIR; > } > > - asprintf(&TMPDIR, "%s/", env_tmpdir); > + if (asprintf(&TMPDIR, "%s/", env_tmpdir) == -1) { > + TMPDIR = (char*)"/tmp/"; > + } > return TMPDIR; > } > > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/core/util.c b/core/util.c index 8c6b295..821b6df 100644 --- a/core/util.c +++ b/core/util.c @@ -71,7 +71,9 @@ const char* get_tmpdir(void) return TMPDIR; } - asprintf(&TMPDIR, "%s/", env_tmpdir); + if (asprintf(&TMPDIR, "%s/", env_tmpdir) == -1) { + TMPDIR = (char*)"/tmp/"; + } return TMPDIR; }
Fix travis's complaint about missing asprintf return value check (-Wunused-result). Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)