From 84f895cb7bea20aafe445d55b70e78687ae2776a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 16 Aug 2000 18:12:43 +0200 Subject: [PATCH] Fixed a few warnings. Rev: src/array.c:1.84 Rev: src/array.h:1.28 Rev: src/fdlib.c:1.38 Rev: src/interpret.c:1.164 Rev: src/language.yacc:1.207 Rev: src/modules/MIME/mime.c:1.25 Rev: src/modules/_Crypto/crypto.c:1.37 Rev: src/modules/call_out/call_out.c:1.38 Rev: src/modules/files/efuns.c:1.83 Rev: src/modules/files/file.c:1.187 Rev: src/pike_memory.c:1.80 Rev: src/pike_memory.h:1.23 --- src/array.c | 10 +++++----- src/array.h | 4 ++-- src/fdlib.c | 14 ++++++++------ src/interpret.c | 6 +++--- src/language.yacc | 6 +++--- src/modules/MIME/mime.c | 9 +++++---- src/modules/_Crypto/crypto.c | 5 +++-- src/modules/call_out/call_out.c | 10 +++++----- src/modules/files/efuns.c | 6 +++--- src/modules/files/file.c | 6 +++--- src/pike_memory.c | 10 +++++----- src/pike_memory.h | 6 +++--- 12 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/array.c b/src/array.c index 72a95fa19e..e3ef72bbe7 100644 --- a/src/array.c +++ b/src/array.c @@ -23,7 +23,7 @@ #include "stuff.h" #include "bignum.h" -RCSID("$Id: array.c,v 1.83 2000/08/15 16:19:12 grubba Exp $"); +RCSID("$Id: array.c,v 1.84 2000/08/16 15:54:07 grubba Exp $"); PMOD_EXPORT struct array empty_array= { @@ -71,8 +71,8 @@ PMOD_EXPORT struct array *low_allocate_array(ptrdiff_t size, ptrdiff_t extra_spa v->type_field=BIT_MIXED | BIT_UNFINISHED; v->flags=0; - v->malloced_size=size+extra_space; - v->size=size; + v->malloced_size = DO_NOT_WARN((INT32)(size + extra_space)); + v->size = DO_NOT_WARN((INT32)size); v->refs=1; LINK_ARRAY(v); @@ -367,7 +367,7 @@ PMOD_EXPORT struct array *resize_array(struct array *a, INT32 size) /* * Shrink an array destructively */ -PMOD_EXPORT struct array *array_shrink(struct array *v,INT32 size) +PMOD_EXPORT struct array *array_shrink(struct array *v, ptrdiff_t size) { struct array *a; @@ -1742,7 +1742,7 @@ PMOD_EXPORT void array_replace(struct array *a, struct svalue *from, struct svalue *to) { - INT32 i = -1; + ptrdiff_t i = -1; while((i=array_search(a,from,i+1)) >= 0) array_set_index(a,i,to); } diff --git a/src/array.h b/src/array.h index 8705db1769..d7011c8aeb 100644 --- a/src/array.h +++ b/src/array.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: array.h,v 1.27 2000/08/15 11:17:20 grubba Exp $ + * $Id: array.h,v 1.28 2000/08/16 15:54:28 grubba Exp $ */ #ifndef ARRAY_H #define ARRAY_H @@ -101,7 +101,7 @@ PMOD_EXPORT void array_set_index(struct array *v,INT32 index, struct svalue *s); PMOD_EXPORT void simple_set_index(struct array *a,struct svalue *ind,struct svalue *s); PMOD_EXPORT struct array *array_insert(struct array *v,struct svalue *s,INT32 index); PMOD_EXPORT struct array *resize_array(struct array *a, INT32 size); -PMOD_EXPORT struct array *array_shrink(struct array *v,INT32 size); +PMOD_EXPORT struct array *array_shrink(struct array *v, ptrdiff_t size); PMOD_EXPORT struct array *array_remove(struct array *v,INT32 index); PMOD_EXPORT ptrdiff_t array_search(struct array *v, struct svalue *s, ptrdiff_t start); diff --git a/src/fdlib.c b/src/fdlib.c index 66f3285a57..d0271ef270 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -3,7 +3,7 @@ #include "error.h" #include <math.h> -RCSID("$Id: fdlib.c,v 1.37 2000/07/28 17:16:55 hubbe Exp $"); +RCSID("$Id: fdlib.c,v 1.38 2000/08/16 15:59:28 grubba Exp $"); #ifdef HAVE_WINSOCK_H @@ -92,8 +92,9 @@ void fd_exit() int debug_fd_stat(char *file, struct stat *buf) { - int l=strlen(file); + ptrdiff_t l = strlen(file); char fname[MAX_PATH]; + if(file[l-1]=='/' || file[l-1]=='\\') { do l--; @@ -117,8 +118,9 @@ PMOD_EXPORT FD debug_fd_open(char *file, int open_mode, int create_mode) FD fd; DWORD omode,cmode,amode; - int l=strlen(file); + ptrdiff_t l = strlen(file); char fname[MAX_PATH]; + if(file[l-1]=='/' || file[l-1]=='\\') { do l--; @@ -440,7 +442,7 @@ PMOD_EXPORT int debug_fd_close(FD fd) PMOD_EXPORT long debug_fd_write(FD fd, void *buf, long len) { - DWORD ret; + SDWORD ret; long handle; mt_lock(&fd_mutex); FDDEBUG(fprintf(stderr,"Writing %d bytes to %d (%d)\n",len,fd,da_handle[fd])); @@ -655,7 +657,7 @@ static long convert_filetime_to_time_t(FILETIME tmp) t=tmp.dwHighDateTime * pow(2.0,32.0) + (double)tmp.dwLowDateTime; t/=10000000.0; t-=11644473600.0; - return (long)floor(t); + return DO_NOT_WARN((long)floor(t)); } PMOD_EXPORT int debug_fd_fstat(FD fd, struct stat *s) @@ -862,7 +864,7 @@ PMOD_EXPORT FD debug_fd_dup2(FD from, FD to) #ifdef EMULATE_DIRECT PMOD_EXPORT DIR *opendir(char *dir) { - int len=strlen(dir); + ptrdiff_t len=strlen(dir); char *foo; DIR *ret=(DIR *)malloc(sizeof(DIR) + len+5); if(!ret) diff --git a/src/interpret.c b/src/interpret.c index 6a866ee02f..b745c0fa6c 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: interpret.c,v 1.163 2000/08/10 19:31:03 grubba Exp $"); +RCSID("$Id: interpret.c,v 1.164 2000/08/16 16:00:52 grubba Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -936,13 +936,13 @@ PMOD_EXPORT void mega_apply2(enum apply_type type, INT32 args, void *arg1, void ref->identifier_offset, ref->id_flags); - fprintf(stderr,"-- context: prog->id=%d inlev=%d idlev=%d pi=%d po=%d so=%d name=%s\n", + fprintf(stderr,"-- context: prog->id=%d inlev=%d idlev=%d pi=%d po=%d so=%ld name=%s\n", new_frame->context.prog->id, new_frame->context.inherit_level, new_frame->context.identifier_level, new_frame->context.parent_identifier, new_frame->context.parent_offset, - new_frame->context.storage_offset, + DO_NOT_WARN((long)new_frame->context.storage_offset), new_frame->context.name ? new_frame->context.name->str : "NULL"); if(t_flag>19) { diff --git a/src/language.yacc b/src/language.yacc index 57ed9df260..f18e96ef81 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -110,7 +110,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.206 2000/08/15 19:00:24 grubba Exp $"); +RCSID("$Id: language.yacc,v 1.207 2000/08/16 16:02:08 grubba Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -474,7 +474,7 @@ import: TOK_IMPORT idents ';' constant_name: TOK_IDENTIFIER '=' safe_expr0 { - int tmp; + ptrdiff_t tmp; /* This can be made more lenient in the future */ /* Ugly hack to make sure that $3 is optimized */ @@ -502,7 +502,7 @@ constant_name: TOK_IDENTIFIER '=' safe_expr0 { yyerror("Error in constant definition."); }else{ - pop_n_elems(tmp-1); + pop_n_elems(DO_NOT_WARN((INT32)(tmp - 1))); add_constant($1->u.sval.u.string, Pike_sp-1, Pike_compiler->current_modifiers & ~ID_EXTERN); pop_stack(); diff --git a/src/modules/MIME/mime.c b/src/modules/MIME/mime.c index 8a3f0b91d3..8e189eaba7 100644 --- a/src/modules/MIME/mime.c +++ b/src/modules/MIME/mime.c @@ -1,5 +1,5 @@ /* - * $Id: mime.c,v 1.24 2000/08/09 18:42:31 grubba Exp $ + * $Id: mime.c,v 1.25 2000/08/16 16:12:43 grubba Exp $ * * RFC1521 functionality for Pike * @@ -10,7 +10,7 @@ #include "config.h" -RCSID("$Id: mime.c,v 1.24 2000/08/09 18:42:31 grubba Exp $"); +RCSID("$Id: mime.c,v 1.25 2000/08/16 16:12:43 grubba Exp $"); #include "stralloc.h" #include "pike_macros.h" #include "object.h" @@ -493,11 +493,12 @@ static void do_uue_encode(ptrdiff_t groups, unsigned char **srcp, char **destp, while (groups || last) { /* A single line can hold at most 15 groups */ - int g = (groups >= 15? 15 : groups); + ptrdiff_t g = (groups >= 15? 15 : groups); if (g<15) { /* The line isn't filled completely. Add space for the "last" bytes */ - *dest++ = ' ' + (3*g + last); + *dest++ = ' ' + + DO_NOT_WARN((char)(3*g + last)); last = 0; } else *dest++ = ' ' + (3*g); diff --git a/src/modules/_Crypto/crypto.c b/src/modules/_Crypto/crypto.c index 7c7bb8e071..f20c97ddcb 100644 --- a/src/modules/_Crypto/crypto.c +++ b/src/modules/_Crypto/crypto.c @@ -1,5 +1,5 @@ /* - * $Id: crypto.c,v 1.36 2000/08/09 21:19:11 grubba Exp $ + * $Id: crypto.c,v 1.37 2000/08/16 16:09:55 grubba Exp $ * * A pike module for getting access to some common cryptos. * @@ -404,7 +404,8 @@ static void f_pad(INT32 args) for (i = THIS->backlog_len; i < THIS->block_size - 1; i++) THIS->backlog[i] = my_rand() & 0xff; - THIS->backlog[THIS->block_size - 1] = 7 - THIS->backlog_len; + THIS->backlog[THIS->block_size - 1] = + DO_NOT_WARN((unsigned char)(7 - THIS->backlog_len)); push_string(make_shared_binary_string((const char *)THIS->backlog, THIS->block_size)); diff --git a/src/modules/call_out/call_out.c b/src/modules/call_out/call_out.c index 5f6d8cabe6..401cf08842 100644 --- a/src/modules/call_out/call_out.c +++ b/src/modules/call_out/call_out.c @@ -6,7 +6,7 @@ /**/ #include "global.h" #include "config.h" -RCSID("$Id: call_out.c,v 1.37 2000/08/07 10:03:01 grubba Exp $"); +RCSID("$Id: call_out.c,v 1.38 2000/08/16 16:08:06 grubba Exp $"); #include "array.h" #include "dynamic_buffer.h" #include "object.h" @@ -355,8 +355,8 @@ static struct array * new_call_out(int num_arg,struct svalue *argp) case T_FLOAT: { FLOAT_TYPE tmp=argp[0].u.float_number; - new->tv.tv_sec=floor(tmp); - new->tv.tv_usec=(long)(1000000.0 * (tmp - floor(tmp))); + new->tv.tv_sec = DO_NOT_WARN((long)floor(tmp)); + new->tv.tv_usec = DO_NOT_WARN((long)(1000000.0 * (tmp - floor(tmp)))); break; } @@ -407,8 +407,8 @@ static void count_memory_in_call_outs(struct callback *foo, push_text("call_out_bytes"); /* FIXME */ - push_int(call_buffer_size * sizeof(call_out **)+ - num_pending_calls * sizeof(call_out)); + push_int64(call_buffer_size * sizeof(call_out **)+ + num_pending_calls * sizeof(call_out)); } static struct callback *call_out_backend_callback=0; diff --git a/src/modules/files/efuns.c b/src/modules/files/efuns.c index 3816a502b1..6716ef1401 100644 --- a/src/modules/files/efuns.c +++ b/src/modules/files/efuns.c @@ -25,7 +25,7 @@ #include "file_machine.h" #include "file.h" -RCSID("$Id: efuns.c,v 1.82 2000/08/02 18:56:35 hubbe Exp $"); +RCSID("$Id: efuns.c,v 1.83 2000/08/16 16:05:31 grubba Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -604,7 +604,7 @@ void f_get_dir(INT32 args) #define FPR 1024 char buffer[MAXPATHLEN * 4]; char *ptrs[FPR]; - int lens[FPR]; + ptrdiff_t lens[FPR]; struct dirent *tmp; if (!(tmp = @@ -733,7 +733,7 @@ void f_get_dir(INT32 args) free(tmp); closedir(dir); THREADS_DISALLOW(); - a=aggregate_array(sp-save_sp); + a = aggregate_array(DO_NOT_WARN((INT32)(sp - save_sp))); } #else dir = opendir(str->str); diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 4e5d57ae8e..01afb059d5 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -6,7 +6,7 @@ /**/ #define NO_PIKE_SHORTHAND #include "global.h" -RCSID("$Id: file.c,v 1.186 2000/08/15 13:05:15 grubba Exp $"); +RCSID("$Id: file.c,v 1.187 2000/08/16 16:06:27 grubba Exp $"); #include "fdlib.h" #include "interpret.h" #include "svalue.h" @@ -1055,7 +1055,7 @@ static void file_write(INT32 args) if (!written) { push_int(-1); } else { - push_int(written); + push_int64(written); } return; @@ -1080,7 +1080,7 @@ static void file_write(INT32 args) ERRNO=0; pop_n_elems(args); - push_int(written); + push_int64(written); } #ifdef WITH_OOB diff --git a/src/pike_memory.c b/src/pike_memory.c index 1b0cac0010..96608188a5 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -10,7 +10,7 @@ #include "pike_macros.h" #include "gc.h" -RCSID("$Id: pike_memory.c,v 1.79 2000/08/11 13:29:02 grubba Exp $"); +RCSID("$Id: pike_memory.c,v 1.80 2000/08/16 15:51:20 grubba Exp $"); /* strdup() is used by several modules, so let's provide it */ #ifndef HAVE_STRDUP @@ -52,13 +52,13 @@ INLINE p_wchar2 *MEMCHR2(p_wchar2 *p, p_wchar2 c, ptrdiff_t e) return (p_wchar2 *)0; } -void swap(char *a, char *b, INT32 size) +void swap(char *a, char *b, size_t size) { - int tmp; + size_t tmp; char tmpbuf[1024]; while(size) { - tmp=MINIMUM((long)sizeof(tmpbuf), size); + tmp = MINIMUM((size_t)sizeof(tmpbuf), size); MEMCPY(tmpbuf,a,tmp); MEMCPY(a,b,tmp); MEMCPY(b,tmpbuf,tmp); @@ -68,7 +68,7 @@ void swap(char *a, char *b, INT32 size) } } -void reverse(char *memory, INT32 nitems, INT32 size) +void reverse(char *memory, size_t nitems, size_t size) { #define DOSIZE(X,Y) \ diff --git a/src/pike_memory.h b/src/pike_memory.h index e2cfc8c432..b51c62f164 100644 --- a/src/pike_memory.h +++ b/src/pike_memory.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: pike_memory.h,v 1.22 2000/08/16 10:28:17 grubba Exp $ + * $Id: pike_memory.h,v 1.23 2000/08/16 15:51:03 grubba Exp $ */ #ifndef MEMORY_H #define MEMORY_H @@ -65,8 +65,8 @@ PMOD_EXPORT ptrdiff_t pcharp_memcmp(PCHARP a, PCHARP b, int sz); PMOD_EXPORT long pcharp_strlen(PCHARP a); PMOD_EXPORT INLINE p_wchar1 *MEMCHR1(p_wchar1 *p, p_wchar1 c, ptrdiff_t e); PMOD_EXPORT INLINE p_wchar2 *MEMCHR2(p_wchar2 *p, p_wchar2 c, ptrdiff_t e); -PMOD_EXPORT void swap(char *a, char *b, INT32 size); -PMOD_EXPORT void reverse(char *memory, INT32 nitems, INT32 size); +PMOD_EXPORT void swap(char *a, char *b, size_t size); +PMOD_EXPORT void reverse(char *memory, size_t nitems, size_t size); PMOD_EXPORT void reorder(char *memory, INT32 nitems, INT32 size,INT32 *order); PMOD_EXPORT size_t hashmem(const unsigned char *a, size_t len, size_t mlen); PMOD_EXPORT size_t hashstr(const unsigned char *str, ptrdiff_t maxn); -- GitLab