summaryrefslogtreecommitdiff
path: root/manual/examples
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1992-12-27 09:29:34 +0000
committerRichard M. Stallman <rms@gnu.org>1992-12-27 09:29:34 +0000
commitc7a6ca7c0f78629b23a112fda9ed64e4239a2539 (patch)
treec2e89dbd421bbe451773d63f106e724155ddeef9 /manual/examples
parent70868912d0df5a72ea32c095c396df9d5ae7f842 (diff)
Fix args of offsetof, and add comment about it.
Diffstat (limited to 'manual/examples')
-rw-r--r--manual/examples/mkfsock.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/manual/examples/mkfsock.c b/manual/examples/mkfsock.c
index 8c09f32441..d3750ec150 100644
--- a/manual/examples/mkfsock.c
+++ b/manual/examples/mkfsock.c
@@ -25,7 +25,14 @@ make_named_socket (const char *filename)
name.sun_family = AF_FILE;
strcpy (name.sun_path, filename);
- size = offsetof (name.sun_path) + strlen (name.sun_path) + 1;
+
+ /* The size of the address is
+ the offset of the start of the filename,
+ plus its length,
+ plus one for the terminating null byte. */
+ size = (offsetof (struct sockaddr_un, sun_path)
+ + strlen (name.sun_path) + 1);
+
if (bind (sock, (struct sockaddr *) &name, size) < 0)
{
perror ("bind");