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

Commit1ed61b3

Browse files
committed
Fix unportable assumptions about alignment of local char[n] variables.
1 parent39ceedf commit1ed61b3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

‎src/interfaces/odbc/socket.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,23 +227,29 @@ SOCK_put_string(SocketClass *self, char *string)
227227
int
228228
SOCK_get_int(SocketClass*self,shortlen)
229229
{
230-
charbuf[4];
231-
232230
switch (len)
233231
{
234232
case2:
235-
SOCK_get_n_char(self,buf,len);
233+
{
234+
unsigned shortbuf;
235+
236+
SOCK_get_n_char(self, (char*)&buf,len);
236237
if (self->reverse)
237-
return*((unsigned short*)buf);
238+
returnbuf;
238239
else
239-
returnntohs(*((unsigned short*)buf));
240+
returnntohs(buf);
241+
}
240242

241243
case4:
242-
SOCK_get_n_char(self,buf,len);
244+
{
245+
unsignedintbuf;
246+
247+
SOCK_get_n_char(self, (char*)&buf,len);
243248
if (self->reverse)
244-
return*((unsignedint*)buf);
249+
returnbuf;
245250
else
246-
returnntohl(*((unsignedint*)buf));
251+
returnntohl(buf);
252+
}
247253

248254
default:
249255
self->errornumber=SOCKET_GET_INT_WRONG_LENGTH;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp