Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161320083
D54412.id169252.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54412.id169252.diff
View Options
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -926,8 +926,8 @@
formataddr(struct sockaddr_storage *ss, char *buf, size_t bufsize)
{
struct sockaddr_un *sun;
- char addrstr[NI_MAXHOST] = { '\0', '\0' };
- int error, off, port = 0;
+ char addrstr[NI_MAXHOST] = "";
+ int error, port = 0;
switch (ss->ss_family) {
case AF_INET:
@@ -942,14 +942,11 @@
break;
case AF_UNIX:
sun = sstosun(ss);
- off = (int)((char *)&sun->sun_path - (char *)sun);
if (is_xo_style_encoding) {
- xo_emit("{:path/%.*s}", sun->sun_len - off,
- sun->sun_path);
- return 0;
+ xo_emit("{:path/%.*s}", SUNPATHLEN, sun->sun_path);
+ return (0);
}
- return snprintf(buf, bufsize, "%.*s",
- sun->sun_len - off, sun->sun_path);
+ return snprintf(buf, bufsize, "%.*s", SUNPATHLEN, sun->sun_path);
}
if (addrstr[0] == '\0') {
error = cap_getnameinfo(capnet, sstosa(ss), ss->ss_len,
@@ -960,11 +957,11 @@
if (is_xo_style_encoding) {
xo_emit("{:address/%s}", addrstr);
xo_emit("{:port/%d}", port);
- return 0;
+ return (0);
}
if (port == 0)
- return snprintf(buf, bufsize, "%s:*", addrstr);
- return snprintf(buf, bufsize, "%s:%d", addrstr, port);
+ return (snprintf(buf, bufsize, "%s:*", addrstr));
+ return (snprintf(buf, bufsize, "%s:%d", addrstr, port));
}
static const char *
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 6:58 PM (14 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34633902
Default Alt Text
D54412.id169252.diff (1 KB)
Attached To
Mode
D54412: sockstat: improve code style
Attached
Detach File
Event Timeline
Log In to Comment