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

Commit3f9c169

Browse files
committed
Fix compiler warnings on 64-bit Windows
GCC reports various instances ofwarning: cast to pointer from integer of different size [-Wint-to-pointer-cast]warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]and MSVC equivalentlywarning C4312: 'type cast': conversion from 'int' to 'void *' of greater sizewarning C4311: 'type cast': pointer truncation from 'void *' to 'long'in ECPG test files. This is because void* and long are cast back andforth, but on 64-bit Windows, these have different sizes. Fix byusing intptr_t instead.The code actually worked fine because the integer values in use areall small. So this is just to get the test code to compile warning-free.This change is simplified by having made stdint.h required (commit9573384). Before this it would havebeen more complicated because the ecpg test source files don't use thefull pg_config.h.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/5d398bbb-262a-5fed-d839-d0e5cff3c0d7%402ndquadrant.com
1 parentb7fabe8 commit3f9c169

File tree

8 files changed

+106
-100
lines changed

8 files changed

+106
-100
lines changed

‎src/interfaces/ecpg/test/expected/thread-alloc.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#defineECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
88

99
#line 1 "alloc.pgc"
10+
#include<stdint.h>
1011
#include<stdlib.h>
1112
#include"ecpg_config.h"
1213

@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
100101

101102
#endif
102103

103-
#line25 "alloc.pgc"
104+
#line26 "alloc.pgc"
104105

105106

106107
#line 1 "regression.h"
@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
110111

111112

112113

113-
#line26 "alloc.pgc"
114+
#line27 "alloc.pgc"
114115

115116

116117
/* exec sql whenever sqlerror sqlprint ; */
117-
#line28 "alloc.pgc"
118+
#line29 "alloc.pgc"
118119

119120
/* exec sql whenever not found sqlprint ; */
120-
#line29 "alloc.pgc"
121+
#line30 "alloc.pgc"
121122

122123

123124
#ifdefWIN32
@@ -133,62 +134,62 @@ static void* fn(void* arg)
133134

134135

135136

136-
#line40 "alloc.pgc"
137+
#line41 "alloc.pgc"
137138
intvalue ;
138139

139-
#line41 "alloc.pgc"
140+
#line42 "alloc.pgc"
140141
charname [100 ] ;
141142

142-
#line42 "alloc.pgc"
143+
#line43 "alloc.pgc"
143144
char**r=NULL ;
144145
/* exec sql end declare section */
145-
#line43 "alloc.pgc"
146+
#line44 "alloc.pgc"
146147

147148

148-
value= (long)arg;
149+
value= (intptr_t)arg;
149150
sprintf(name,"Connection: %d",value);
150151

151152
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,name,0);
152-
#line48 "alloc.pgc"
153+
#line49 "alloc.pgc"
153154

154155
if (sqlca.sqlcode<0)sqlprint();}
155-
#line48 "alloc.pgc"
156+
#line49 "alloc.pgc"
156157

157158
{ECPGsetcommit(__LINE__,"on",NULL);
158-
#line49 "alloc.pgc"
159+
#line50 "alloc.pgc"
159160

160161
if (sqlca.sqlcode<0)sqlprint();}
161-
#line49 "alloc.pgc"
162+
#line50 "alloc.pgc"
162163

163164
for (i=1;i <=REPEATS;++i)
164165
{
165166
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"select relname from pg_class where relname = 'pg_class'",ECPGt_EOIT,
166167
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
167168
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EORT);
168-
#line52 "alloc.pgc"
169+
#line53 "alloc.pgc"
169170

170171
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
171-
#line52 "alloc.pgc"
172+
#line53 "alloc.pgc"
172173

173174
if (sqlca.sqlcode<0)sqlprint();}
174-
#line52 "alloc.pgc"
175+
#line53 "alloc.pgc"
175176

176177
free(r);
177178
r=NULL;
178179
}
179180
{ECPGdisconnect(__LINE__,name);
180-
#line56 "alloc.pgc"
181+
#line57 "alloc.pgc"
181182

182183
if (sqlca.sqlcode<0)sqlprint();}
183-
#line56 "alloc.pgc"
184+
#line57 "alloc.pgc"
184185

185186

186187
return0;
187188
}
188189

189190
intmain ()
190191
{
191-
inti;
192+
intptr_ti;
192193
#ifdefWIN32
193194
HANDLEthreads[THREADS];
194195
#else
@@ -207,7 +208,7 @@ int main ()
207208
CloseHandle(threads[i]);
208209
#else
209210
for (i=0;i<THREADS;++i)
210-
pthread_create(&threads[i],NULL,fn, (void*)(long)i);
211+
pthread_create(&threads[i],NULL,fn, (void*)i);
211212
for (i=0;i<THREADS;++i)
212213
pthread_join(threads[i],NULL);
213214
#endif

‎src/interfaces/ecpg/test/expected/thread-prep.c

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#defineECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
88

99
#line 1 "prep.pgc"
10+
#include<stdint.h>
1011
#include<stdlib.h>
1112
#include"ecpg_config.h"
1213

@@ -100,7 +101,7 @@ struct sqlca_t *ECPGget_sqlca(void);
100101

101102
#endif
102103

103-
#line25 "prep.pgc"
104+
#line26 "prep.pgc"
104105

105106

106107
#line 1 "regression.h"
@@ -110,14 +111,14 @@ struct sqlca_t *ECPGget_sqlca(void);
110111

111112

112113

113-
#line26 "prep.pgc"
114+
#line27 "prep.pgc"
114115

115116

116117
/* exec sql whenever sqlerror sqlprint ; */
117-
#line28 "prep.pgc"
118+
#line29 "prep.pgc"
118119

119120
/* exec sql whenever not found sqlprint ; */
120-
#line29 "prep.pgc"
121+
#line30 "prep.pgc"
121122

122123

123124
#ifdefWIN32
@@ -133,108 +134,108 @@ static void* fn(void* arg)
133134

134135

135136

136-
#line40 "prep.pgc"
137+
#line41 "prep.pgc"
137138
intvalue ;
138139

139-
#line41 "prep.pgc"
140+
#line42 "prep.pgc"
140141
charname [100 ] ;
141142

142-
#line42 "prep.pgc"
143+
#line43 "prep.pgc"
143144
charquery [256 ]="INSERT INTO T VALUES ( ? )" ;
144145
/* exec sql end declare section */
145-
#line43 "prep.pgc"
146+
#line44 "prep.pgc"
146147

147148

148-
value= (long)arg;
149+
value= (intptr_t)arg;
149150
sprintf(name,"Connection: %d",value);
150151

151152
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,name,0);
152-
#line48 "prep.pgc"
153+
#line49 "prep.pgc"
153154

154155
if (sqlca.sqlcode<0)sqlprint();}
155-
#line48 "prep.pgc"
156+
#line49 "prep.pgc"
156157

157158
{ECPGsetcommit(__LINE__,"on",NULL);
158-
#line49 "prep.pgc"
159+
#line50 "prep.pgc"
159160

160161
if (sqlca.sqlcode<0)sqlprint();}
161-
#line49 "prep.pgc"
162+
#line50 "prep.pgc"
162163

163164
for (i=1;i <=REPEATS;++i)
164165
{
165166
{ECPGprepare(__LINE__,NULL,0,"i",query);
166-
#line52 "prep.pgc"
167+
#line53 "prep.pgc"
167168

168169
if (sqlca.sqlcode<0)sqlprint();}
169-
#line52 "prep.pgc"
170+
#line53 "prep.pgc"
170171

171172
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_execute,"i",
172173
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
173174
ECPGt_NO_INDICATOR,NULL ,0L,0L,0L,ECPGt_EOIT,ECPGt_EORT);
174-
#line53 "prep.pgc"
175+
#line54 "prep.pgc"
175176

176177
if (sqlca.sqlcode==ECPG_NOT_FOUND)sqlprint();
177-
#line53 "prep.pgc"
178+
#line54 "prep.pgc"
178179

179180
if (sqlca.sqlcode<0)sqlprint();}
180-
#line53 "prep.pgc"
181+
#line54 "prep.pgc"
181182

182183
}
183184
{ECPGdeallocate(__LINE__,0,NULL,"i");
184-
#line55 "prep.pgc"
185+
#line56 "prep.pgc"
185186

186187
if (sqlca.sqlcode<0)sqlprint();}
187-
#line55 "prep.pgc"
188+
#line56 "prep.pgc"
188189

189190
{ECPGdisconnect(__LINE__,name);
190-
#line56 "prep.pgc"
191+
#line57 "prep.pgc"
191192

192193
if (sqlca.sqlcode<0)sqlprint();}
193-
#line56 "prep.pgc"
194+
#line57 "prep.pgc"
194195

195196

196197
return0;
197198
}
198199

199200
intmain ()
200201
{
201-
inti;
202+
intptr_ti;
202203
#ifdefWIN32
203204
HANDLEthreads[THREADS];
204205
#else
205206
pthread_tthreads[THREADS];
206207
#endif
207208

208209
{ECPGconnect(__LINE__,0,"ecpg1_regression" ,NULL,NULL ,NULL,0);
209-
#line 70 "prep.pgc"
210-
211-
if (sqlca.sqlcode<0)sqlprint();}
212-
#line 70 "prep.pgc"
213-
214-
{ECPGsetcommit(__LINE__,"on",NULL);
215210
#line 71 "prep.pgc"
216211

217212
if (sqlca.sqlcode<0)sqlprint();}
218213
#line 71 "prep.pgc"
219214

220-
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop table if exists T",ECPGt_EOIT,ECPGt_EORT);
215+
{ECPGsetcommit(__LINE__,"on",NULL);
221216
#line 72 "prep.pgc"
222217

223218
if (sqlca.sqlcode<0)sqlprint();}
224219
#line 72 "prep.pgc"
225220

226-
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"create tableT ( i int )",ECPGt_EOIT,ECPGt_EORT);
221+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"drop tableif exists T",ECPGt_EOIT,ECPGt_EORT);
227222
#line 73 "prep.pgc"
228223

229224
if (sqlca.sqlcode<0)sqlprint();}
230225
#line 73 "prep.pgc"
231226

232-
{ECPGdisconnect(__LINE__,"CURRENT");
227+
{ECPGdo(__LINE__,0,1,NULL,0,ECPGst_normal,"create table T ( i int )",ECPGt_EOIT,ECPGt_EORT);
233228
#line 74 "prep.pgc"
234229

235230
if (sqlca.sqlcode<0)sqlprint();}
236231
#line 74 "prep.pgc"
237232

233+
{ECPGdisconnect(__LINE__,"CURRENT");
234+
#line 75 "prep.pgc"
235+
236+
if (sqlca.sqlcode<0)sqlprint();}
237+
#line 75 "prep.pgc"
238+
238239

239240
#ifdefWIN32
240241
for (i=0;i<THREADS;++i)
@@ -248,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
248249
CloseHandle(threads[i]);
249250
#else
250251
for (i=0;i<THREADS;++i)
251-
pthread_create(&threads[i],NULL,fn, (void*)(long)i);
252+
pthread_create(&threads[i],NULL,fn, (void*)i);
252253
for (i=0;i<THREADS;++i)
253254
pthread_join(threads[i],NULL);
254255
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp