X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Feffi.c;h=ded16d479fa53ca3841ae64c7a702b6f6fe5ed9d;hb=a6c43f113a6323407b6786b98f867124515e7bf0;hp=ad4b27d5ecfc9f36b02ab5eb8936b1c5a9d9b491;hpb=786d7ecc150c784b1049150802fdd4bf411a0d07;p=sxemacs
diff --git a/src/effi.c b/src/effi.c
index ad4b27d..ded16d4 100644
--- a/src/effi.c
+++ b/src/effi.c
@@ -24,7 +24,7 @@ along with this program. If not, see . */
#include
#include
-
+#include "sysdep.h"
#include "effi.h"
#include "buffer.h"
@@ -55,11 +55,19 @@ along with this program. If not, see . */
# define SIGNAL_ERROR signal_error
# define FFIBYTE Bufbyte
# define WRITE_C_STRING(x,y) write_c_string((x),(y))
+# define WRITE_FMT_STRING(x,y,...) write_fmt_string((x),(y),__VA_ARGS__)
# define LRECORD_DESCRIPTION lrecord_description
#else
# define SIGNAL_ERROR Fsignal
# define FFIBYTE Ibyte
# define WRITE_C_STRING(x,y) write_c_string((y),(x))
+# define WRITE_FMT_STRING(x,y,...) \
+ do { \
+ char wcsb[128]; \
+ int wcss = snprintf(wcsb, sizeof(wcsb), \
+ (y),__VA_ARGS__); \
+ write_c_string((y),wcsb); \
+ } while(0)
# define LRECORD_DESCRIPTION memory_description
#endif /* SXEMACS */
@@ -143,8 +151,6 @@ print_ffiobject(Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
{
/* This function can GC */
Lisp_EffiObject *ffio = XEFFIO(obj);
- char buf[256];
-
escapeflag = escapeflag; /* shutup compiler */
if (print_readably) {
#ifdef SXEMACS
@@ -163,9 +169,8 @@ print_ffiobject(Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
print_internal(ffio->type, printcharfun, 1);
WRITE_C_STRING(" ", printcharfun);
}
- snprintf(buf, 255, "size=%ld fotype=%d foptr=%p>",
- (long)XINT(ffio->size), ffio->fotype, ffio->fop.generic);
- WRITE_C_STRING(buf, printcharfun);
+ WRITE_FMT_STRING(printcharfun,"size=%ld fotype=%d foptr=%p>",
+ (long)XINT(ffio->size), ffio->fotype, ffio->fop.generic);
}
static const struct LRECORD_DESCRIPTION ffiobject_description[] = {
@@ -612,9 +617,11 @@ $LD_LIBRARY_PATH environment variable or the more global ld.so.cache.
/* Add an extension if we need to */
dotpos = strrchr((char *)XSTRING_DATA(libname),'.');
if ( dotpos == NULL || strncmp(dotpos, EXT, sizeof(EXT))) {
- soname = xmalloc(XSTRING_LENGTH(libname) + sizeof(EXT) + 1);
- strcpy(soname, (char *)XSTRING_DATA(libname));
- strcat(soname, EXT);
+ ssize_t liblen = XSTRING_LENGTH(libname);
+ ssize_t soname_len = liblen + sizeof(EXT);
+ soname = xmalloc( soname_len + 1);
+ strncpy(soname, (char *)XSTRING_DATA(libname), liblen+1);
+ strncat(soname, EXT, sizeof(EXT)+1);
}
if ( soname == NULL ) {
@@ -1387,7 +1394,7 @@ ARGS should be foreign data objects or pointers to these.
Lisp_Object Qffi_jobp;
#define EFFI_DEBUG_JOB(args...)
static Lisp_Object
-exec_sentinel_unwind(Lisp_Object UNUSED(datum))
+exec_sentinel_unwind(Lisp_Object SXE_UNUSED(datum))
{
return Qnil;
}
@@ -1495,12 +1502,10 @@ static void
print_ffi_job(worker_job_t job, Lisp_Object pcf)
{
ffi_job_t ffij = ffi_job(job);
- char *str = alloca(64);
SXE_MUTEX_LOCK(&ffij->mtx);
- WRITE_C_STRING(" carrying ", pcf);
- snprintf(str, 63, " #", (long unsigned int)ffij);
- WRITE_C_STRING(str, pcf);
+ WRITE_FMT_STRING(pcf, " carrying #",
+ (long unsigned int)ffij);
SXE_MUTEX_UNLOCK(&ffij->mtx);
return;
}