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

Commit174f984

Browse files
author
Thomas G. Lockhart
committed
Use SHRT_MIN and SHRT_MAX for 2-byte integer limits.
1 parente7946a5 commit174f984

File tree

1 file changed

+15
-5
lines changed
  • src/backend/utils/adt

1 file changed

+15
-5
lines changed

‎src/backend/utils/adt/int.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.9 1997/10/25 05:19:22 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.10 1997/11/17 16:24:17 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -30,11 +30,21 @@
3030
*/
3131
#include<stdio.h>
3232
#include<string.h>
33+
#ifdefHAVE_LIMITS
34+
#include<limits.h>
35+
#endif
3336

3437
#include"postgres.h"
3538
#include"fmgr.h"
3639
#include"utils/builtins.h"/* where the declarations go */
3740

41+
#ifndefSHRT_MAX
42+
#defineSHRT_MAX (0x7FFF)
43+
#endif
44+
#ifndefSHRT_MIN
45+
#defineSHRT_MIN (-0x8000)
46+
#endif
47+
3848
/*****************************************************************************
3949
* USER I/O ROUTINES *
4050
*****************************************************************************/
@@ -221,10 +231,10 @@ i2toi4(int16 arg1)
221231
int16
222232
i4toi2(int32arg1)
223233
{
224-
if (arg1<-0x8000)
225-
elog(NOTICE,"i4toi2:\"%d\" causes int2 underflow",arg1);
226-
if (arg1>0x7FFF)
227-
elog(NOTICE,"i4toi2:\"%d\" causes int2 overflow",arg1);
234+
if (arg1<SHRT_MIN)
235+
elog(WARN,"i4toi2:'%d' causes int2 underflow",arg1);
236+
if (arg1>SHRT_MAX)
237+
elog(WARN,"i4toi2:'%d' causes int2 overflow",arg1);
228238

229239
return ((int16)arg1);
230240
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp