1. Use socklen_t instead of int

2. Compare socket(2) return code to -1, not <= 0.

Obtained from:	OpenBSD rev. 1.9
This commit is contained in:
Colin Percival 2004-03-21 08:14:39 +00:00
parent 64bf80ce1b
commit a616808417
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127263

View File

@ -68,7 +68,7 @@ CTL_MSG msg;
void
open_sockt()
{
int length;
socklen_t length;
(void)memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
@ -76,7 +76,7 @@ open_sockt()
my_addr.sin_addr = my_machine_addr;
my_addr.sin_port = 0;
sockt = socket(AF_INET, SOCK_STREAM, 0);
if (sockt <= 0)
if (sockt == -1)
p_error("Bad socket");
if (bind(sockt, (struct sockaddr *)&my_addr, sizeof(my_addr)) != 0)
p_error("Binding local socket");
@ -89,7 +89,7 @@ open_sockt()
void
open_ctl()
{
int length;
socklen_t length;
(void)memset(&ctl_addr, 0, sizeof(ctl_addr));
ctl_addr.sin_family = AF_INET;
@ -97,7 +97,7 @@ open_ctl()
ctl_addr.sin_port = 0;
ctl_addr.sin_addr = my_machine_addr;
ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0);
if (ctl_sockt <= 0)
if (ctl_sockt == -1)
p_error("Bad socket");
if (bind(ctl_sockt,
(struct sockaddr *)&ctl_addr, sizeof(ctl_addr)) != 0)