diff options
author | Thiago Farina <tfransosi@gmail.com> | 2010-12-03 23:32:08 -0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-12-14 11:27:57 -0800 |
commit | d6e76cca7b54f9e692481f878c663f97748e8ad9 (patch) | |
tree | 1d2370fd9c1b4789c99890db30a9fe84b8a24826 | |
parent | f28629471c737da5af23db627b750a4b4666c89d (diff) | |
download | uemacs-d6e76cca7b54f9e692481f878c663f97748e8ad9.tar.gz |
uemacs: input.c: Fix mkstemp warning.
Fix the following warning:
input.c: In function ‘getstring’:
input.c:590: warning: ignoring return value of ‘mkstemp’, declared with attribute warn_unused_result
This add usage.c module for die function.
This also add wrapper.c module for the xmkstemp that is wrapper function
around the original mkstemp function.
Both module codes was largelly based on git, linux and sparse codes.
Signed-off-by: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | input.c | 16 | ||||
-rw-r--r-- | usage.c | 22 | ||||
-rw-r--r-- | usage.h | 6 | ||||
-rw-r--r-- | wrapper.c | 14 | ||||
-rw-r--r-- | wrapper.h | 6 |
6 files changed, 61 insertions, 9 deletions
@@ -19,12 +19,14 @@ PROGRAM=em SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c ibmpc.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c vmsvt.c vt52.c window.c word.c names.c globals.c version.c + termio.c vmsvt.c vt52.c window.c word.c names.c globals.c version.c \ + usage.c wrapper.c OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o ibmpc.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o vmsvt.o vt52.o window.o word.o names.o globals.o version.o + termio.o vmsvt.o vt52.o window.o word.o names.o globals.o version.o \ + usage.o wrapper.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h @@ -1,4 +1,4 @@ -/* INPUT.C +/* input.c * * Various input routines * @@ -6,11 +6,13 @@ * modified by Petri Kutvonen */ -#include <stdio.h> -#include <unistd.h> -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include <stdio.h> +#include <unistd.h> + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "wrapper.h" #if PKCODE #if MSDOS && TURBO @@ -587,7 +589,7 @@ int getstring(char *prompt, char *buf, int nbuf, int eolchar) if (!iswild) strcat(ffbuf, "*"); strcat(ffbuf, " >"); - mkstemp(tmp); + xmkstemp(tmp); strcat(ffbuf, tmp); strcat(ffbuf, " 2>&1"); system(ffbuf); @@ -0,0 +1,22 @@ +#include "usage.h" + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +static void report(const char* prefix, const char *err, va_list params) +{ + char msg[4096]; + vsnprintf(msg, sizeof(msg), err, params); + fprintf(stderr, "%s%s\n", prefix, msg); +} + +void die(const char* err, ...) +{ + va_list params; + + va_start(params, err); + report("fatal: ", err, params); + va_end(params); + exit(128); +} @@ -0,0 +1,6 @@ +#ifndef USAGE_H_ +#define USAGE_H_ + +extern void die(const char* err, ...); + +#endif /* USAGE_H_ */ diff --git a/wrapper.c b/wrapper.c new file mode 100644 index 0000000..4bf8d7e --- /dev/null +++ b/wrapper.c @@ -0,0 +1,14 @@ +#include "usage.h" + +#include <stdlib.h> + +/* Function copyright: git */ +int xmkstemp(char *template) +{ + int fd; + + fd = mkstemp(template); + if (fd < 0) + die("Unable to create temporary file"); + return fd; +} diff --git a/wrapper.h b/wrapper.h new file mode 100644 index 0000000..0db3b8f --- /dev/null +++ b/wrapper.h @@ -0,0 +1,6 @@ +#ifndef WRAPPER_H_ +#define WRAPPER_H_ + +extern int xmkstemp(char *template); + +#endif /* WRAPPER_H_ */ |