Discussion:
talk(1)/ntalkd(8) headers cleanup
Ricardo Mestre
2016-01-26 19:14:48 UTC
Permalink
Hi tech@,

Below is an header cleanup to both talk(1) and ntalkd(8), also remove some
lint-style comments and swap hardcoded program string with __progname.

If someone OK's and/or commits this then I'll send afterwards a diff to pledge
both as well after applying this.

Index: libexec/talkd/announce.c
===================================================================
RCS file: /cvs/src/libexec/talkd/announce.c,v
retrieving revision 1.23
diff -u -p -u -r1.23 announce.c
--- libexec/talkd/announce.c 16 Jan 2015 06:39:51 -0000 1.23
+++ libexec/talkd/announce.c 26 Jan 2016 18:46:57 -0000
@@ -29,21 +29,16 @@
* SUCH DAMAGE.
*/

-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
#include <protocols/talkd.h>
-#include <errno.h>
-#include <syslog.h>
-#include <unistd.h>
+
#include <limits.h>
+#include <paths.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <vis.h>
-#include <paths.h>
+
#include "talkd.h"

static void print_mesg(FILE *,CTL_MSG *,char *);
Index: libexec/talkd/print.c
===================================================================
RCS file: /cvs/src/libexec/talkd/print.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 print.c
--- libexec/talkd/print.c 27 Oct 2009 23:59:31 -0000 1.11
+++ libexec/talkd/print.c 26 Jan 2016 18:46:57 -0000
@@ -31,12 +31,11 @@

/* debug print routines */

-#include <sys/types.h>
#include <sys/socket.h>
#include <protocols/talkd.h>
-#include <syslog.h>
+
#include <stdio.h>
-#include "talkd.h"
+#include <syslog.h>

static char *types[] = {
"leave_invite", "look_up", "delete", "announce"
Index: libexec/talkd/process.c
===================================================================
RCS file: /cvs/src/libexec/talkd/process.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 process.c
--- libexec/talkd/process.c 16 Jan 2015 06:39:51 -0000 1.21
+++ libexec/talkd/process.c 26 Jan 2016 18:46:57 -0000
@@ -37,18 +37,20 @@
* in the table for the local user
* DELETE - delete invitation
*/
-#include <sys/stat.h>
#include <sys/socket.h>
-#include <netinet/in.h>
+#include <sys/stat.h>
#include <arpa/inet.h>
#include <protocols/talkd.h>
+
+#include <ctype.h>
+#include <limits.h>
#include <netdb.h>
-#include <syslog.h>
+#include <paths.h>
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
-#include <paths.h>
-#include <limits.h>
+#include <syslog.h>
+#include <utmp.h>
+
#include "talkd.h"

#define satosin(sa) ((struct sockaddr_in *)(sa))
@@ -179,8 +181,6 @@ do_announce(CTL_MSG *mp, CTL_RESPONSE *r
rp->answer = SUCCESS;
}
}
-
-#include <utmp.h>

/*
* Search utmp for the local user
Index: libexec/talkd/table.c
===================================================================
RCS file: /cvs/src/libexec/talkd/table.c,v
retrieving revision 1.16
diff -u -p -u -r1.16 table.c
--- libexec/talkd/table.c 16 Jan 2015 06:39:51 -0000 1.16
+++ libexec/talkd/table.c 26 Jan 2016 18:46:57 -0000
@@ -37,15 +37,15 @@
*
* Consider this a mis-guided attempt at modularity
*/
-#include <sys/time.h>
-#include <sys/socket.h>
#include <sys/queue.h>
+#include <sys/socket.h>
#include <protocols/talkd.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <stdio.h>
+
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+
#include "talkd.h"

#define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */
Index: libexec/talkd/talkd.c
===================================================================
RCS file: /cvs/src/libexec/talkd/talkd.c,v
retrieving revision 1.23
diff -u -p -u -r1.23 talkd.c
--- libexec/talkd/talkd.c 16 Jan 2015 06:39:51 -0000 1.23
+++ libexec/talkd/talkd.c 26 Jan 2016 18:46:57 -0000
@@ -35,19 +35,19 @@
* disconnect all descriptors and ttys, and then endless
* loop on waiting for and processing requests
*/
-#include <sys/types.h>
#include <sys/socket.h>
#include <protocols/talkd.h>
-#include <signal.h>
-#include <syslog.h>
-#include <time.h>
+
#include <errno.h>
-#include <unistd.h>
#include <limits.h>
+#include <paths.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <paths.h>
+#include <syslog.h>
+#include <unistd.h>
+
#include "talkd.h"

int debug = 0;
Index: usr.bin/talk/ctl.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/ctl.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 ctl.c
--- usr.bin/talk/ctl.c 12 Aug 2010 23:31:29 -0000 1.12
+++ usr.bin/talk/ctl.c 26 Jan 2016 18:47:04 -0000
@@ -36,9 +36,10 @@
* the progress
*/

+#include <sys/socket.h>
+#include <arpa/inet.h>
+
#include "talk.h"
-#include <arpa/inet.h>
-#include "talk_ctl.h"

struct sockaddr_in daemon_addr = { sizeof(daemon_addr), AF_INET };
struct sockaddr_in ctl_addr = { sizeof(ctl_addr), AF_INET };
Index: usr.bin/talk/ctl_transact.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/ctl_transact.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 ctl_transact.c
--- usr.bin/talk/ctl_transact.c 12 Aug 2010 23:31:29 -0000 1.12
+++ usr.bin/talk/ctl_transact.c 26 Jan 2016 18:47:04 -0000
@@ -30,11 +30,13 @@
* SUCH DAMAGE.
*/

-#include "talk.h"
-#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
#include <errno.h>
-#include <unistd.h>
#include <poll.h>
+
+#include "talk.h"
#include "talk_ctl.h"

#define CTL_WAIT 2 /* time to wait for a response, in seconds */
Index: usr.bin/talk/display.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/display.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 display.c
--- usr.bin/talk/display.c 28 Nov 2013 18:24:55 -0000 1.17
+++ usr.bin/talk/display.c 26 Jan 2016 18:47:04 -0000
@@ -34,8 +34,9 @@
* The window 'manager', initializes curses and handles the actual
* displaying of text
*/
-#include "talk.h"
#include <ctype.h>
+
+#include "talk.h"

xwin_t my_win;
xwin_t his_win;
Index: usr.bin/talk/get_addrs.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/get_addrs.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 get_addrs.c
--- usr.bin/talk/get_addrs.c 12 Aug 2010 23:31:29 -0000 1.9
+++ usr.bin/talk/get_addrs.c 26 Jan 2016 18:47:04 -0000
@@ -30,10 +30,12 @@
* SUCH DAMAGE.
*/

-#include "talk.h"
+#include <err.h>
#include <netdb.h>
-#include <stdio.h>
+#include <string.h>
#include <unistd.h>
+
+#include "talk.h"
#include "talk_ctl.h"

void
Index: usr.bin/talk/get_names.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/get_names.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 get_names.c
--- usr.bin/talk/get_names.c 16 Jan 2015 06:40:13 -0000 1.20
+++ usr.bin/talk/get_names.c 26 Jan 2016 18:47:04 -0000
@@ -30,11 +30,16 @@
* SUCH DAMAGE.
*/

-#include "talk.h"
+#include <sys/socket.h>
+
+#include <err.h>
+#include <limits.h>
#include <pwd.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <limits.h>
+
+#include "talk.h"

extern CTL_MSG msg;

@@ -66,7 +71,8 @@ get_names(int argc, char *argv[])
}

if ((argc < 2 ) || ('@' == argv[1][0])) {
- fprintf(stderr, "usage: talk [-Hs] person [ttyname]\n");
+ extern char *__progname;
+ fprintf(stderr, "usage: %s [-Hs] person [ttyname]\n", __progname);
exit(1);
}
if (!isatty(STDIN_FILENO))
Index: usr.bin/talk/init_disp.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/init_disp.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 init_disp.c
--- usr.bin/talk/init_disp.c 11 Dec 2013 14:28:20 -0000 1.21
+++ usr.bin/talk/init_disp.c 26 Jan 2016 18:47:04 -0000
@@ -35,12 +35,14 @@
* as well as the signal handling routines.
*/

-#include "talk.h"
#include <sys/ioctl.h>
+
#include <err.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
+
+#include "talk.h"

/*
* Set up curses, catch the appropriate signals,
Index: usr.bin/talk/invite.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/invite.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 invite.c
--- usr.bin/talk/invite.c 11 Mar 2013 17:40:11 -0000 1.15
+++ usr.bin/talk/invite.c 26 Jan 2016 18:47:04 -0000
@@ -30,13 +30,16 @@
* SUCH DAMAGE.
*/

-#include "talk.h"
+#include <sys/socket.h>
#include <arpa/inet.h>
-#include <sys/time.h>
-#include <netdb.h>
+
+#include <err.h>
#include <errno.h>
+#include <netdb.h>
#include <setjmp.h>
#include <unistd.h>
+
+#include "talk.h"
#include "talk_ctl.h"

#define STRING_LENGTH 158
Index: usr.bin/talk/io.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/io.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 io.c
--- usr.bin/talk/io.c 12 Aug 2010 23:31:29 -0000 1.18
+++ usr.bin/talk/io.c 26 Jan 2016 18:47:04 -0000
@@ -36,13 +36,13 @@
* ctl.c
*/

-#include "talk.h"
#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <poll.h>
+
#include <errno.h>
+#include <poll.h>
#include <unistd.h>
+
+#include "talk.h"

#define A_LONG_TIME 1000000

Index: usr.bin/talk/look_up.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/look_up.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 look_up.c
--- usr.bin/talk/look_up.c 12 Aug 2010 23:31:29 -0000 1.12
+++ usr.bin/talk/look_up.c 26 Jan 2016 18:47:05 -0000
@@ -30,9 +30,12 @@
* SUCH DAMAGE.
*/

-#include "talk.h"
+#include <sys/socket.h>
+
#include <errno.h>
#include <unistd.h>
+
+#include "talk.h"
#include "talk_ctl.h"

/*
@@ -81,7 +84,6 @@ check_local(void)
return (0);
}
quit("Unable to connect with initiator", 1);
- /*NOTREACHED*/
return (0);
}

Index: usr.bin/talk/msgs.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/msgs.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 msgs.c
--- usr.bin/talk/msgs.c 12 Aug 2010 23:31:29 -0000 1.10
+++ usr.bin/talk/msgs.c 26 Jan 2016 18:47:05 -0000
@@ -36,8 +36,6 @@
*/

#include "talk.h"
-#include <sys/time.h>
-#include <stdio.h>

#define MSG_INTERVAL 4

Index: usr.bin/talk/talk.c
===================================================================
RCS file: /cvs/src/usr.bin/talk/talk.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 talk.c
--- usr.bin/talk/talk.c 27 Oct 2009 23:59:44 -0000 1.9
+++ usr.bin/talk/talk.c 26 Jan 2016 18:47:05 -0000
@@ -30,6 +30,10 @@
* SUCH DAMAGE.
*/

+#include <err.h>
+#include <string.h>
+#include <unistd.h>
+
#include "talk.h"

/*
@@ -59,6 +63,5 @@ main(int argc, char *argv[])
end_msgs();
set_edit_chars();
talk();
- /* NOTREACHED */
return (0);
}
Index: usr.bin/talk/talk.h
===================================================================
RCS file: /cvs/src/usr.bin/talk/talk.h,v
retrieving revision 1.11
diff -u -p -u -r1.11 talk.h
--- usr.bin/talk/talk.h 9 May 2009 11:05:01 -0000 1.11
+++ usr.bin/talk/talk.h 26 Jan 2016 18:47:05 -0000
@@ -32,14 +32,11 @@
* @(#)talk.h 8.1 (Berkeley) 6/6/93
*/

-#include <sys/types.h>
-#include <sys/socket.h>
#include <netinet/in.h>
#include <protocols/talkd.h>
+
#include <curses.h>
#include <signal.h>
-#include <string.h>
-#include <err.h>

extern int sockt;
extern int curses_initialized;

Loading...