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

Commit53d52a6

Browse files
committed
Cleanup of NULL in inet types.
1 parent419b91c commit53d52a6

File tree

2 files changed

+81
-71
lines changed

2 files changed

+81
-71
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
*PostgreSQL type definitions for MAC addresses.
33
*
4-
*$Id: mac.c,v 1.6 1998/10/26 01:01:36 tgl Exp $
4+
*$Id: mac.c,v 1.7 1999/03/22 05:00:57 momjian Exp $
55
*/
66

77
#include<stdio.h>
@@ -156,7 +156,6 @@ macaddr_in(char *str)
156156

157157
if (strlen(str)>0)
158158
{
159-
160159
count=sscanf(str,"%x:%x:%x:%x:%x:%x",&a,&b,&c,&d,&e,&f);
161160
if (count!=6)
162161
count=sscanf(str,"%x-%x-%x-%x-%x-%x",&a,&b,&c,&d,&e,&f);
@@ -168,18 +167,12 @@ macaddr_in(char *str)
168167
count=sscanf(str,"%2x%2x.%2x%2x.%2x%2x",&a,&b,&c,&d,&e,&f);
169168

170169
if (count!=6)
171-
{
172170
elog(ERROR,"macaddr_in: error in parsing \"%s\"",str);
173-
return (NULL);
174-
}
175171

176172
if ((a<0)|| (a>255)|| (b<0)|| (b>255)||
177173
(c<0)|| (c>255)|| (d<0)|| (d>255)||
178174
(e<0)|| (e>255)|| (f<0)|| (f>255))
179-
{
180175
elog(ERROR,"macaddr_in: illegal address \"%s\"",str);
181-
return (NULL);
182-
}
183176
}
184177
else
185178
{
@@ -232,40 +225,52 @@ macaddr_out(macaddr *addr)
232225
bool
233226
macaddr_lt(macaddr*a1,macaddr*a2)
234227
{
228+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
229+
return FALSE;
235230
return ((hibits(a1)<hibits(a2))||
236231
((hibits(a1)==hibits(a2))&&lobits(a1)<lobits(a2)));
237232
}
238233

239234
bool
240235
macaddr_le(macaddr*a1,macaddr*a2)
241236
{
237+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
238+
return FALSE;
242239
return ((hibits(a1)<hibits(a2))||
243240
((hibits(a1)==hibits(a2))&&lobits(a1) <=lobits(a2)));
244241
}
245242

246243
bool
247244
macaddr_eq(macaddr*a1,macaddr*a2)
248245
{
246+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
247+
return FALSE;
249248
return ((hibits(a1)==hibits(a2))&& (lobits(a1)==lobits(a2)));
250249
}
251250

252251
bool
253252
macaddr_ge(macaddr*a1,macaddr*a2)
254253
{
254+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
255+
return FALSE;
255256
return ((hibits(a1)>hibits(a2))||
256257
((hibits(a1)==hibits(a2))&&lobits(a1) >=lobits(a2)));
257258
}
258259

259260
bool
260261
macaddr_gt(macaddr*a1,macaddr*a2)
261262
{
263+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
264+
return FALSE;
262265
return ((hibits(a1)>hibits(a2))||
263266
((hibits(a1)==hibits(a2))&&lobits(a1)>lobits(a2)));
264267
}
265268

266269
bool
267270
macaddr_ne(macaddr*a1,macaddr*a2)
268271
{
272+
if (!PointerIsValid(a1)|| !PointerIsValid(a2))
273+
return FALSE;
269274
return ((hibits(a1)!=hibits(a2))|| (lobits(a1)!=lobits(a2)));
270275
}
271276

@@ -299,6 +304,9 @@ macaddr_manuf(macaddr *addr)
299304
intlength;
300305
text*result;
301306

307+
if (!PointerIsValid(addr))
308+
returnNULL;
309+
302310
for (manuf=manufacturers;manuf->name!=NULL;manuf++)
303311
{
304312
if ((manuf->a==addr->a)&&

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp