mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
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>
This commit is contained in:
parent
f28629471c
commit
d6e76cca7b
6
Makefile
6
Makefile
@ -19,12 +19,14 @@ PROGRAM=em
|
|||||||
SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \
|
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 \
|
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 \
|
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 \
|
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 \
|
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 \
|
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
|
HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h
|
||||||
|
|
||||||
|
16
input.c
16
input.c
@ -1,4 +1,4 @@
|
|||||||
/* INPUT.C
|
/* input.c
|
||||||
*
|
*
|
||||||
* Various input routines
|
* Various input routines
|
||||||
*
|
*
|
||||||
@ -6,11 +6,13 @@
|
|||||||
* modified by Petri Kutvonen
|
* modified by Petri Kutvonen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "estruct.h"
|
|
||||||
#include "edef.h"
|
#include "estruct.h"
|
||||||
#include "efunc.h"
|
#include "edef.h"
|
||||||
|
#include "efunc.h"
|
||||||
|
#include "wrapper.h"
|
||||||
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
#if MSDOS && TURBO
|
#if MSDOS && TURBO
|
||||||
@ -587,7 +589,7 @@ int getstring(char *prompt, char *buf, int nbuf, int eolchar)
|
|||||||
if (!iswild)
|
if (!iswild)
|
||||||
strcat(ffbuf, "*");
|
strcat(ffbuf, "*");
|
||||||
strcat(ffbuf, " >");
|
strcat(ffbuf, " >");
|
||||||
mkstemp(tmp);
|
xmkstemp(tmp);
|
||||||
strcat(ffbuf, tmp);
|
strcat(ffbuf, tmp);
|
||||||
strcat(ffbuf, " 2>&1");
|
strcat(ffbuf, " 2>&1");
|
||||||
system(ffbuf);
|
system(ffbuf);
|
||||||
|
22
usage.c
Normal file
22
usage.c
Normal file
@ -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);
|
||||||
|
}
|
6
usage.h
Normal file
6
usage.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef USAGE_H_
|
||||||
|
#define USAGE_H_
|
||||||
|
|
||||||
|
extern void die(const char* err, ...);
|
||||||
|
|
||||||
|
#endif /* USAGE_H_ */
|
14
wrapper.c
Normal file
14
wrapper.c
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user