Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0bdf46a

Browse files
committed
Fix some actual bugs exposed by compiler warnings.
(Someone forgot whether their subroutine signaled errors by a NULL pointer return value, or a negative integer... I'm surprised gcc -Wall doesn't catch this...)
1 parent 3d87216 commit 0bdf46a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/utils/adt/network.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* is for IP V4 CIDR notation, but prepared for V6: just
44
* add the necessary bits where the comments indicate.
55
*
6-
* $Id: network.c,v 1.1 1998/10/22 20:40:46 momjian Exp $
6+
* $Id: network.c,v 1.2 1998/10/26 01:03:24 tgl Exp $
77
* Jon Postel RIP 16 Oct 1998
88
*/
99

@@ -313,7 +313,7 @@ network_host(inet *ip)
313313
if (ip_family(ip) == AF_INET)
314314
{
315315
/* It's an IP V4 address: */
316-
if (inet_net_ntop(AF_INET, &ip_v4addr(ip), 32, tmp, sizeof(tmp)) < 0)
316+
if (inet_net_ntop(AF_INET, &ip_v4addr(ip), 32, tmp, sizeof(tmp)) == NULL)
317317
{
318318
elog(ERROR, "unable to print host (%s)", strerror(errno));
319319
return (NULL);
@@ -358,7 +358,7 @@ network_broadcast(inet *ip)
358358
/* It's an IP V4 address: */
359359
int addr = htonl(ntohl(ip_v4addr(ip)) | (0xffffffff >> ip_bits(ip)));
360360

361-
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) < 0)
361+
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
362362
{
363363
elog(ERROR, "unable to print address (%s)", strerror(errno));
364364
return (NULL);
@@ -397,7 +397,7 @@ network_network(inet *ip)
397397
/* It's an IP V4 address: */
398398
int addr = ntohl(ip_v4addr(ip)) & (0xffffffff << (32 - ip_bits(ip)));
399399

400-
if (inet_cidr_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) < 0)
400+
if (inet_cidr_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
401401
{
402402
elog(ERROR, "unable to print network (%s)", strerror(errno));
403403
return (NULL);
@@ -436,7 +436,7 @@ network_netmask(inet *ip)
436436
/* It's an IP V4 address: */
437437
int addr = htonl((-1 << (32 - ip_bits(ip))) & 0xffffffff);
438438

439-
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) < 0)
439+
if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
440440
{
441441
elog(ERROR, "unable to print netmask (%s)", strerror(errno));
442442
return (NULL);

0 commit comments

Comments
 (0)