From 4bf8150e1fb36f171faa9d8d2a85dad262f64723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sun, 2 Nov 1997 19:50:31 +0100 Subject: [PATCH] Added some casts. Rev: src/modules/Image/colortable.c:1.17 Rev: src/modules/Image/encodings/gif.c:1.7 Rev: src/modules/Image/encodings/pnm.c:1.2 Rev: src/modules/Image/lzw.c:1.6 Rev: src/modules/Msql/msqlmod.c:1.3 Rev: src/modules/Odbc/odbc.c:1.5 Rev: src/modules/Odbc/odbc_result.c:1.6 --- src/modules/Image/colortable.c | 9 +++++---- src/modules/Image/encodings/gif.c | 24 ++++++++++++------------ src/modules/Image/encodings/pnm.c | 12 ++++++------ src/modules/Image/lzw.c | 10 +++++----- src/modules/Msql/msqlmod.c | 20 ++++++++++---------- src/modules/Odbc/odbc.c | 19 +++++++++++-------- src/modules/Odbc/odbc_result.c | 9 +++++---- 7 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c index f19f2e9890..c46d0e5ad4 100644 --- a/src/modules/Image/colortable.c +++ b/src/modules/Image/colortable.c @@ -1,11 +1,11 @@ #include <config.h> -/* $Id: colortable.c,v 1.16 1997/11/02 03:58:41 mirar Exp $ */ +/* $Id: colortable.c,v 1.17 1997/11/02 18:48:32 grubba Exp $ */ /* **! module Image **! note -**! $Id: colortable.c,v 1.16 1997/11/02 03:58:41 mirar Exp $ +**! $Id: colortable.c,v 1.17 1997/11/02 18:48:32 grubba Exp $ **! class colortable **! **! This object keeps colortable information, @@ -21,7 +21,7 @@ #undef COLORTABLE_REDUCE_DEBUG #include "global.h" -RCSID("$Id: colortable.c,v 1.16 1997/11/02 03:58:41 mirar Exp $"); +RCSID("$Id: colortable.c,v 1.17 1997/11/02 18:48:32 grubba Exp $"); #include <sys/types.h> #include <sys/stat.h> @@ -2953,7 +2953,8 @@ void image_colortable_index_8bit(INT32 args) ps=begin_shared_string(src->xsize*src->ysize); - if (!image_colortable_index_8bit_image(THIS,src->img,ps->str, + if (!image_colortable_index_8bit_image(THIS,src->img, + (unsigned char *)ps->str, src->xsize*src->ysize,src->xsize)) { error("colortable->index_8bit(): called colortable is not initiated\n"); diff --git a/src/modules/Image/encodings/gif.c b/src/modules/Image/encodings/gif.c index ea8001e4e3..8208f8e955 100644 --- a/src/modules/Image/encodings/gif.c +++ b/src/modules/Image/encodings/gif.c @@ -1,9 +1,9 @@ -/* $Id: gif.c,v 1.6 1997/11/02 03:44:49 mirar Exp $ */ +/* $Id: gif.c,v 1.7 1997/11/02 18:50:30 grubba Exp $ */ /* **! module Image **! note -**! $Id: gif.c,v 1.6 1997/11/02 03:44:49 mirar Exp $ +**! $Id: gif.c,v 1.7 1997/11/02 18:50:30 grubba Exp $ **! submodule GIF **! **! This submodule keep the GIF encode/decode capabilities @@ -21,7 +21,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: gif.c,v 1.6 1997/11/02 03:44:49 mirar Exp $"); +RCSID("$Id: gif.c,v 1.7 1997/11/02 18:50:30 grubba Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -240,7 +240,7 @@ void image_gif_header_block(INT32 args) if (globalpalette) { ps=begin_shared_string((1<<bpp)*3); - image_colortable_write_rgb(nct,ps->str); + image_colortable_write_rgb(nct,(unsigned char *)ps->str); MEMSET(ps->str+(numcolors+alphaentry)*3,0,((1<<bpp)-numcolors)*3); if (alphaentry) @@ -474,18 +474,18 @@ void image_gif__render_block(INT32 args) THREADS_ALLOW(); if (!interlace) - image_gif_lzw_add(&lzw,ips->str,ips->len); + image_gif_lzw_add(&lzw,(unsigned char *)ips->str,ips->len); else { int y; for (y=0; y<ys; y+=8) - image_gif_lzw_add(&lzw,ips->str+y*xs,xs); + image_gif_lzw_add(&lzw,((unsigned char *)ips->str)+y*xs,xs); for (y=4; y<ys; y+=8) - image_gif_lzw_add(&lzw,ips->str+y*xs,xs); + image_gif_lzw_add(&lzw,((unsigned char *)ips->str)+y*xs,xs); for (y=2; y<ys; y+=4) - image_gif_lzw_add(&lzw,ips->str+y*xs,xs); + image_gif_lzw_add(&lzw,((unsigned char *)ips->str)+y*xs,xs); for (y=1; y<ys; y+=2) - image_gif_lzw_add(&lzw,ips->str+y*xs,xs); + image_gif_lzw_add(&lzw,((unsigned char *)ips->str)+y*xs,xs); } image_gif_lzw_finish(&lzw); @@ -745,14 +745,14 @@ void image_gif_render_block(INT32 args) } ps=begin_shared_string(img->xsize*img->ysize); - image_colortable_index_8bit_image(nct,img->img,ps->str, + image_colortable_index_8bit_image(nct,img->img,(unsigned char *)ps->str, img->xsize*img->ysize,img->xsize); if (alpha) { rgb_group *a=alpha->img; int n=img->xsize*img->ysize; - unsigned char *d=ps->str; + unsigned char *d=(unsigned char *)ps->str; while (n--) { if (a->r||a->g||a->b) @@ -775,7 +775,7 @@ void image_gif_render_block(INT32 args) int numcolors=image_colortable_size(nct); ps=begin_shared_string((1<<bpp)*3); - image_colortable_write_rgb(nct,ps->str); + image_colortable_write_rgb(nct,(unsigned char *)ps->str); MEMSET(ps->str+(numcolors+alphaentry)*3,0,((1<<bpp)-numcolors)*3); if (alphaentry) { diff --git a/src/modules/Image/encodings/pnm.c b/src/modules/Image/encodings/pnm.c index f65c71698f..291bd5668e 100644 --- a/src/modules/Image/encodings/pnm.c +++ b/src/modules/Image/encodings/pnm.c @@ -1,9 +1,9 @@ -/* $Id: pnm.c,v 1.1 1997/11/02 03:42:38 mirar Exp $ */ +/* $Id: pnm.c,v 1.2 1997/11/02 18:50:31 grubba Exp $ */ /* **! module Image **! note -**! $Id: pnm.c,v 1.1 1997/11/02 03:42:38 mirar Exp $ +**! $Id: pnm.c,v 1.2 1997/11/02 18:50:31 grubba Exp $ **! submodule PNM **! **! This submodule keep the PNM encode/decode capabilities @@ -34,7 +34,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: pnm.c,v 1.1 1997/11/02 03:42:38 mirar Exp $"); +RCSID("$Id: pnm.c,v 1.2 1997/11/02 18:50:31 grubba Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -191,9 +191,9 @@ void img_pnm_decode(INT32 args) (unsigned char)((c*255L)/maxval); break; case '6': - d->r=(unsigned char)((getnext(s,&pos)*255L)/maxval); - d->g=(unsigned char)((getnext(s,&pos)*255L)/maxval); - d->b=(unsigned char)((getnext(s,&pos)*255L)/maxval); + d->r=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval); + d->g=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval); + d->b=(unsigned char)((((INT32)getnext(s,&pos))*255L)/maxval); break; } d++; diff --git a/src/modules/Image/lzw.c b/src/modules/Image/lzw.c index 5a1466d455..d7f85c10f6 100644 --- a/src/modules/Image/lzw.c +++ b/src/modules/Image/lzw.c @@ -1,4 +1,4 @@ -/* $Id: lzw.c,v 1.5 1997/10/27 22:41:23 mirar Exp $ */ +/* $Id: lzw.c,v 1.6 1997/11/02 18:48:33 grubba Exp $ */ /* @@ -15,7 +15,7 @@ the existanse of #define GIF_LZW is for that purpose. :-) /* **! module Image **! note -**! $Id: lzw.c,v 1.5 1997/10/27 22:41:23 mirar Exp $ +**! $Id: lzw.c,v 1.6 1997/11/02 18:48:33 grubba Exp $ */ #include "global.h" @@ -312,7 +312,7 @@ unsigned long lzw_unpack(unsigned char *dest,unsigned long destlen, else if (last==LZWCNULL) { last=current; - if (last>end) break; + if ((int)last>end) break; *(dest++)=(unsigned char)current; wrote++; first=current; @@ -340,7 +340,7 @@ unsigned long lzw_unpack(unsigned char *dest,unsigned long destlen, dest2=dest; n=current; *--dest2=code[n].c; - while (n>end) + while ((int)n>end) { n=code[n].parent; *--dest2=code[n].c; @@ -365,7 +365,7 @@ unsigned long lzw_unpack(unsigned char *dest,unsigned long destlen, code[used].len=code[last].len+1; used++; - if (used>=(1<<cbits)) + if (((int)used)>=(1<<cbits)) { cbits++; #ifdef UNPACK_DEBUG diff --git a/src/modules/Msql/msqlmod.c b/src/modules/Msql/msqlmod.c index 1c93844408..1d2de7511f 100644 --- a/src/modules/Msql/msqlmod.c +++ b/src/modules/Msql/msqlmod.c @@ -2,7 +2,7 @@ * This code is (C) Francesco Chemolli, 1997. * You may use, modify and redistribute it freely under the terms * of the GNU General Public License, version 2. - * $Id: msqlmod.c,v 1.2 1997/10/15 00:07:58 grubba Exp $ + * $Id: msqlmod.c,v 1.3 1997/11/02 18:34:57 grubba Exp $ * * This versione is intended for Pike/0.5 and later. * It won't compile under older versions of the Pike interpreter. @@ -35,7 +35,7 @@ #include "multiset.h" #include <module_support.h> -RCSID("$Id: msqlmod.c,v 1.2 1997/10/15 00:07:58 grubba Exp $"); +RCSID("$Id: msqlmod.c,v 1.3 1997/11/02 18:34:57 grubba Exp $"); #ifdef _REENTRANT MUTEX_T pike_msql_mutex; @@ -65,13 +65,13 @@ static char * decode_msql_type (int msql_type) #endif default: return "unknown"; } -}; +} struct msql_my_data { int socket; /* the communication socket between us and the database engine. */ - int db_selected:1; /*flag: if we selected a database*/ - int connected:1; /*flag: we connected to a server*/ + unsigned int db_selected:1; /*flag: if we selected a database*/ + unsigned int connected:1; /*flag: we connected to a server*/ struct pike_string *error_msg; #ifdef MSQL_VERSION_2 int affected; @@ -266,7 +266,7 @@ static void do_list_dbs (INT32 args) while ((row=msqlFetchRow(result))) /*it's fast, we're in RAM*/ { numrows++; - push_text(row[0]); + push_text((char *)row[0]); } f_aggregate(numrows); msqlFreeResult(result); @@ -311,7 +311,7 @@ static void do_list_tables (INT32 args) while ((row=msqlFetchRow(result))) { numrows++; - push_text(row[0]); + push_text((char *)row[0]); } f_aggregate(numrows); msqlFreeResult(result); @@ -449,9 +449,9 @@ static void do_query (INT32 args) case UINT_TYPE: /*this may lose the MSB and overflow. Is htere a better way?*/ #endif - case INT_TYPE: push_int(atoi(row[k])); break; - case REAL_TYPE: push_float(atof(row[k])); break; - default: push_text(row[k]); break; + case INT_TYPE: push_int(atoi((char *)row[k])); break; + case REAL_TYPE: push_float(atof((char *)row[k])); break; + default: push_text((char *)row[k]); break; } } this_row=aggregate_array(num_fields); diff --git a/src/modules/Odbc/odbc.c b/src/modules/Odbc/odbc.c index c9dc22fce4..ae7840b084 100644 --- a/src/modules/Odbc/odbc.c +++ b/src/modules/Odbc/odbc.c @@ -1,5 +1,5 @@ /* - * $Id: odbc.c,v 1.4 1997/08/15 20:20:10 grubba Exp $ + * $Id: odbc.c,v 1.5 1997/11/02 18:42:12 grubba Exp $ * * Pike interface to ODBC compliant databases. * @@ -15,7 +15,7 @@ #endif /* HAVE_CONFIG_H */ #include "global.h" -RCSID("$Id: odbc.c,v 1.4 1997/08/15 20:20:10 grubba Exp $"); +RCSID("$Id: odbc.c,v 1.5 1997/11/02 18:42:12 grubba Exp $"); #include "interpret.h" #include "object.h" @@ -63,8 +63,8 @@ volatile void odbc_error(const char *fun, const char *msg, RETCODE code, void (*clean)(void)) { RETCODE _code; - char errcode[256]; - char errmsg[SQL_MAX_MESSAGE_LENGTH]; + unsigned char errcode[256]; + unsigned char errmsg[SQL_MAX_MESSAGE_LENGTH]; SWORD errmsg_len = 0; SDWORD native_error; @@ -76,7 +76,7 @@ volatile void odbc_error(const char *fun, const char *msg, if (odbc->last_error) { free_string(odbc->last_error); } - odbc->last_error = make_shared_binary_string(errmsg, errmsg_len); + odbc->last_error = make_shared_binary_string((char *)errmsg, errmsg_len); } if (clean) { @@ -211,8 +211,10 @@ static void f_create(INT32 args) server = make_shared_string(""); } odbc_check_error("odbc->create", "Connect failed", - SQLConnect(PIKE_ODBC->hdbc, server->str, server->len, - user->str, user->len, pwd->str, pwd->len), NULL); + SQLConnect(PIKE_ODBC->hdbc, (unsigned char *)server->str, + server->len, (unsigned char *)user->str, + user->len, (unsigned char *)pwd->str, + pwd->len), NULL); pop_n_elems(args); } @@ -243,7 +245,8 @@ static void f_big_query(INT32 args) SQLAllocStmt(PIKE_ODBC->hdbc, &hstmt), NULL); PIKE_ODBC->hstmt = hstmt; odbc_check_error("odbc->big_query", "Query failed", - SQLExecDirect(hstmt, q->str, q->len), NULL); + SQLExecDirect(hstmt, (unsigned char *)q->str, + q->len), NULL); pop_n_elems(args); odbc_check_error("odbc->big_query", "Couldn't get the number of fields", diff --git a/src/modules/Odbc/odbc_result.c b/src/modules/Odbc/odbc_result.c index 110e681374..8fdfcd9716 100644 --- a/src/modules/Odbc/odbc_result.c +++ b/src/modules/Odbc/odbc_result.c @@ -1,5 +1,5 @@ /* - * $Id: odbc_result.c,v 1.5 1997/09/15 20:39:34 grubba Exp $ + * $Id: odbc_result.c,v 1.6 1997/11/02 18:41:59 grubba Exp $ * * Pike interface to ODBC compliant databases * @@ -17,7 +17,7 @@ #ifdef HAVE_ODBC #include "global.h" -RCSID("$Id: odbc_result.c,v 1.5 1997/09/15 20:39:34 grubba Exp $"); +RCSID("$Id: odbc_result.c,v 1.6 1997/11/02 18:41:59 grubba Exp $"); #include "interpret.h" #include "object.h" @@ -109,7 +109,7 @@ static void odbc_fix_fields(void) int size; } *odbc_fields = alloca(sizeof(struct odbc_field_info)*PIKE_ODBC_RES->num_fields); size_t buf_size = 1024; - char *buf = alloca(buf_size); + unsigned char *buf = alloca(buf_size); int membuf_size = 0; char *membuf = NULL; @@ -147,7 +147,8 @@ static void odbc_fix_fields(void) odbc_fields[i].type = T_STRING; odbc_fields[i].size = precision+1; /* Create the mapping */ - push_text("name"); push_string(make_shared_binary_string(buf, name_len)); + push_text("name"); + push_string(make_shared_binary_string((char *)buf, name_len)); push_text("type"); switch(sql_type) { case SQL_CHAR: -- GitLab