Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35d5d96

Browse files
author
Michael Meskes
committed
Some cleanup in ecpg code:
Use bool as type for booleans instead of int.Do not implicitely cast size_t to int.Make the compiler stop complaining about unused variables by adding an empty statement.
1 parent8c843ff commit35d5d96

File tree

8 files changed

+30
-18
lines changed

8 files changed

+30
-18
lines changed

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ deccopy(decimal *src, decimal *target)
178178
staticchar*
179179
ecpg_strndup(constchar*str,size_tlen)
180180
{
181-
intreal_len=strlen(str);
182-
intuse_len= (real_len>len) ?(int)len :real_len;
181+
size_treal_len=strlen(str);
182+
intuse_len= (int) ((real_len>len) ?len :real_len);
183183

184184
char*new=malloc(use_len+1);
185185

@@ -983,24 +983,33 @@ ldchar(char *src, int len, char *dest)
983983
int
984984
rgetmsg(intmsgnum,char*s,intmaxsize)
985985
{
986+
(void)msgnum;/* keep the compiler quiet */
987+
(void)s;/* keep the compiler quiet */
988+
(void)maxsize;/* keep the compiler quiet */
986989
return0;
987990
}
988991

989992
int
990993
rtypalign(intoffset,inttype)
991994
{
995+
(void)offset;/* keep the compiler quiet */
996+
(void)type;/* keep the compiler quiet */
992997
return0;
993998
}
994999

9951000
int
9961001
rtypmsize(inttype,intlen)
9971002
{
1003+
(void)type;/* keep the compiler quiet */
1004+
(void)len;/* keep the compiler quiet */
9981005
return0;
9991006
}
10001007

10011008
int
10021009
rtypwidth(intsqltype,intsqllen)
10031010
{
1011+
(void)sqltype;/* keep the compiler quiet */
1012+
(void)sqllen;/* keep the compiler quiet */
10041013
return0;
10051014
}
10061015

‎src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
214214
char*sqlstate=PQresultErrorField(result,PG_DIAG_SQLSTATE);
215215
char*message=PQresultErrorField(result,PG_DIAG_MESSAGE_PRIMARY);
216216
structsqlca_t*sqlca=ECPGget_sqlca();
217-
218217
intsqlcode;
219218

219+
(void)arg;/* keep the compiler quiet */
220220
if (sqlstate==NULL)
221221
sqlstate=ECPG_SQLSTATE_ECPG_INTERNAL_ERROR;
222222

‎src/interfaces/ecpg/ecpglib/extern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct connection
7676
{
7777
char*name;
7878
PGconn*connection;
79-
intautocommit;
79+
boolautocommit;
8080
structECPGtype_information_cache*cache_head;
8181
structprepared_statement*prep_stmts;
8282
structconnection*next;

‎src/interfaces/ecpg/ecpglib/memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static pthread_once_t auto_mem_once = PTHREAD_ONCE_INIT;
7575
staticvoid
7676
auto_mem_destructor(void*arg)
7777
{
78+
(void)arg;/* keep the compiler quiet */
7879
ECPGfree_auto_mem();
7980
}
8081

‎src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ replace_variables(char **text, int lineno)
100100
}
101101

102102
staticbool
103-
prepare_common(intlineno,structconnection*con,constboolquestionmarks,constchar*name,constchar*variable)
103+
prepare_common(intlineno,structconnection*con,constchar*name,constchar*variable)
104104
{
105105
structstatement*stmt;
106106
structprepared_statement*this;
@@ -156,14 +156,15 @@ prepare_common(int lineno, struct connection * con, const bool questionmarks, co
156156
}
157157

158158
/* handle the EXEC SQL PREPARE statement */
159-
/* questionmarks is not needed butremians in there for the time being to not change the API */
159+
/* questionmarks is not needed butremains in there for the time being to not change the API */
160160
bool
161161
ECPGprepare(intlineno,constchar*connection_name,constboolquestionmarks,constchar*name,constchar*variable)
162162
{
163163
structconnection*con;
164164
structprepared_statement*this,
165165
*prev;
166166

167+
(void)questionmarks;/* quiet the compiler */
167168
con=ecpg_get_connection(connection_name);
168169

169170
if (!ecpg_init(con,connection_name,lineno))
@@ -174,7 +175,7 @@ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, c
174175
if (this&& !deallocate_one(lineno,ECPG_COMPAT_PGSQL,con,prev,this))
175176
return false;
176177

177-
returnprepare_common(lineno,con,questionmarks,name,variable);
178+
returnprepare_common(lineno,con,name,variable);
178179
}
179180

180181
structprepared_statement*
@@ -304,6 +305,7 @@ ecpg_prepared(const char *name, struct connection * con)
304305
char*
305306
ECPGprepared_statement(constchar*connection_name,constchar*name,intlineno)
306307
{
308+
(void)lineno;/* keep the compiler quiet */
307309
returnecpg_prepared(name,ecpg_get_connection(connection_name));
308310
}
309311

@@ -484,7 +486,7 @@ ecpg_auto_prepare(int lineno, const char *connection_name, const int compat, cha
484486
con=ecpg_get_connection(connection_name);
485487
prep=ecpg_find_prepared_statement(stmtID,con,NULL);
486488
/* This prepared name doesn't exist on this connection. */
487-
if (!prep&& !prepare_common(lineno,con,0,stmtID,query))
489+
if (!prep&& !prepare_common(lineno,con,stmtID,query))
488490
return (false);
489491

490492
*name=ecpg_strdup(stmtID,lineno);

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
#include"extern.h"
1313

14-
intret_value=0,
15-
autocommit= false,
14+
intret_value=0;
15+
boolautocommit= false,
1616
auto_create_c= false,
1717
system_includes= false,
1818
force_indicator= true,
@@ -126,9 +126,9 @@ main(int argc, char *const argv[])
126126

127127
intfnr,
128128
c,
129-
verbose= false,
130-
header_mode= false,
131129
out_option=0;
130+
boolverbose= false,
131+
header_mode= false;
132132
struct_include_path*ip;
133133
constchar*progname;
134134
charmy_exec_path[MAXPGPATH];

‎src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ prepared_name: name {
270270
$$ = $1;
271271
else /* not quoted => convert to lowercase */
272272
{
273-
int i;
273+
size_t i;
274274

275275
for (i = 0; i< strlen($1); i++)
276276
$1[i] = tolower((unsigned char) $1[i]);

‎src/interfaces/ecpg/preproc/extern.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
/* variables */
2020

21-
externintbraces_open,
22-
autocommit,
21+
externboolautocommit,
2322
auto_create_c,
2423
system_includes,
2524
force_indicator,
2625
questionmarks,
27-
ret_value,
28-
struct_level,
29-
ecpg_internal_var,
3026
regression_mode,
3127
auto_prepare;
28+
externintbraces_open,
29+
ret_value,
30+
struct_level,
31+
ecpg_internal_var;
3232
externchar*current_function;
3333
externchar*descriptor_index;
3434
externchar*descriptor_name;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp