this makes it easier to call sbcreatecontrol without requiring casts.

it makes the argument const as well, and promotes the length variable to
size_t.

ok?

Index: sys/socketvar.h
===================================================================
RCS file: /cvs/src/sys/sys/socketvar.h,v
retrieving revision 1.88
diff -u -p -r1.88 socketvar.h
--- sys/socketvar.h     19 Nov 2018 13:15:37 -0000      1.88
+++ sys/socketvar.h     12 Feb 2019 23:52:42 -0000
@@ -290,7 +290,7 @@ int sbappendcontrol(struct socket *, str
 void   sbappendrecord(struct socket *, struct sockbuf *, struct mbuf *);
 void   sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
 struct mbuf *
-       sbcreatecontrol(caddr_t p, int size, int type, int level);
+       sbcreatecontrol(const void *, size_t, int type, int level);
 void   sbdrop(struct socket *, struct sockbuf *, int);
 void   sbdroprecord(struct sockbuf *sb);
 void   sbflush(struct socket *, struct sockbuf *);
Index: kern/uipc_socket2.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_socket2.c,v
retrieving revision 1.99
diff -u -p -r1.99 uipc_socket2.c
--- kern/uipc_socket2.c 19 Nov 2018 13:15:37 -0000      1.99
+++ kern/uipc_socket2.c 12 Feb 2019 23:52:42 -0000
@@ -1020,14 +1020,14 @@ sbdroprecord(struct sockbuf *sb)
  * with the specified type for presentation on a socket buffer.
  */
 struct mbuf *
-sbcreatecontrol(caddr_t p, int size, int type, int level)
+sbcreatecontrol(const void *p, size_t size, int type, int level)
 {
        struct cmsghdr *cp;
        struct mbuf *m;
 
        if (CMSG_SPACE(size) > MCLBYTES) {
-               printf("sbcreatecontrol: message too large %d\n", size);
-               return NULL;
+               printf("sbcreatecontrol: message too large %zu\n", size);
+               return (NULL);
        }
 
        if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL)

Reply via email to