[28810] in Source-Commits
discuss commit: Correct compiler warnings
daemon@ATHENA.MIT.EDU (Lizhou Sha)
Sat Nov 11 19:11:08 2017
Date: Sat, 11 Nov 2017 19:11:00 -0500
From: Lizhou Sha <slz@mit.edu>
Message-Id: <201711120011.vAC0B07U030685@drugstore.mit.edu>
To: source-commits@mit.edu
https://github.com/mit-athena/discuss/commit/832df353d2b92d024aa78ddd6b8d0bfdea2a641c
commit 832df353d2b92d024aa78ddd6b8d0bfdea2a641c
Author: Jonathon Weiss <jweiss@mit.edu>
Date: Wed May 24 12:54:31 2017 -0400
Correct compiler warnings
Use #include and replace gets with fgets.
client/edit.c | 4 +++-
client/new_trans.c | 1 +
client/rn.c | 2 ++
edsc/do_quote.c | 1 +
edsc/do_trn.c | 2 +-
edsc/parse.c | 1 +
libds/announce.c | 1 +
libds/rpcall.c | 1 +
libds/tmem.c | 1 +
mclient/create_mtg_dir.c | 1 +
mclient/crmtgs.c | 1 +
mclient/dspipe.c | 1 +
mclient/mkds.c | 14 +++++++-------
server/acl_core.c | 1 +
server/atom.c | 2 ++
server/disserve.c | 1 +
usp/internal.c | 1 +
17 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/client/edit.c b/client/edit.c
index 41d148b..8b7213b 100644
--- a/client/edit.c
+++ b/client/edit.c
@@ -18,10 +18,12 @@ static char rcsid_discuss_utils_c[] =
"$Id: edit.c,v 1.16 1999-02-02 20:39:46 kcr Exp $";
#endif /* lint */
+#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#include <string.h>
#include <signal.h>
+#include <unistd.h>
#include <ss/ss.h>
#include <discuss/discuss.h>
#include "globals.h"
@@ -98,7 +100,7 @@ edit(fn, edit_path)
fchmod(fileno(the_file), 0700);
printf("Enter transaction; end with ^D or '.' on a line by itself.\n");
for (;;) {
- if ((gets(buffer) == NULL) || interrupt || !strcmp(buffer, ".")) break;
+ if ((fgets(buffer, sizeof(buffer), stdin) == NULL) || interrupt || !strcmp(buffer, ".")) break;
else if (!strcmp(buffer,"\\f")) {
editor_path_2 = editor_path_e;
break;
diff --git a/client/new_trans.c b/client/new_trans.c
index 5c933af..b31daee 100644
--- a/client/new_trans.c
+++ b/client/new_trans.c
@@ -18,6 +18,7 @@ static char rcsid_discuss_c[] =
"$Id: new_trans.c,v 1.30 2006-03-10 07:11:31 ghudson Exp $";
#endif /* lint */
+#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#include <signal.h>
diff --git a/client/rn.c b/client/rn.c
index ccad1ad..b3ebb58 100644
--- a/client/rn.c
+++ b/client/rn.c
@@ -17,7 +17,9 @@ static char rcsid_update_c[] =
#include <discuss/discuss.h>
#include "globals.h"
+#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
diff --git a/edsc/do_quote.c b/edsc/do_quote.c
index 2db9850..07b8660 100644
--- a/edsc/do_quote.c
+++ b/edsc/do_quote.c
@@ -16,6 +16,7 @@ static char rcsid_do_quote_c[] = "$Id: do_quote.c,v 1.4 2006-03-10 07:11:37 ghud
#endif /* lint */
#include <stdlib.h>
+#include <string.h>
/*
*
diff --git a/edsc/do_trn.c b/edsc/do_trn.c
index 4432ca8..87c17a0 100644
--- a/edsc/do_trn.c
+++ b/edsc/do_trn.c
@@ -533,7 +533,7 @@ char *args;
}
/* Read the subject */
- if (gets(subject) == NULL) {
+ if (fgets(subject, sizeof(subject), stdin) == NULL) {
printf(";End of file\n");
exit(1);
}
diff --git a/edsc/parse.c b/edsc/parse.c
index 366ff79..0ab6728 100644
--- a/edsc/parse.c
+++ b/edsc/parse.c
@@ -12,6 +12,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <ctype.h>
#define EAT_SPACE(x) \
diff --git a/libds/announce.c b/libds/announce.c
index 9a0009b..099b540 100644
--- a/libds/announce.c
+++ b/libds/announce.c
@@ -15,6 +15,7 @@ static char rcsid_announce_c[] =
"$Id: announce.c,v 1.10 1999-02-08 14:47:07 danw Exp $";
#endif /* lint */
+#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#if HAVE_FCNTL_H
diff --git a/libds/rpcall.c b/libds/rpcall.c
index 1d0cae7..14762cd 100644
--- a/libds/rpcall.c
+++ b/libds/rpcall.c
@@ -34,6 +34,7 @@ static char rcsid_rpcall_c[] =
#include <netdb.h>
#if HAVE_FCNTL_H
#include <fcntl.h>
+#include <unistd.h>
#endif
#include <discuss/tfile.h>
#include "rpc.h"
diff --git a/libds/tmem.c b/libds/tmem.c
index 1c3d99e..cb103ee 100644
--- a/libds/tmem.c
+++ b/libds/tmem.c
@@ -19,6 +19,7 @@ static char rcsid_tmem_c[] =
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <discuss/tfile.h>
diff --git a/mclient/create_mtg_dir.c b/mclient/create_mtg_dir.c
index 3fe352e..38d03ba 100644
--- a/mclient/create_mtg_dir.c
+++ b/mclient/create_mtg_dir.c
@@ -10,6 +10,7 @@
* However, it is secure..
*/
+#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/param.h>
diff --git a/mclient/crmtgs.c b/mclient/crmtgs.c
index 5ba9fcb..d95ff03 100644
--- a/mclient/crmtgs.c
+++ b/mclient/crmtgs.c
@@ -20,6 +20,7 @@ static char rcsid_crmtgs_c[] =
"$Id: crmtgs.c,v 1.7 1999-04-12 16:47:06 ghudson Exp $";
#endif /* lint */
+#include <stdlib.h>
#include <stdio.h>
#include <discuss/discuss.h>
diff --git a/mclient/dspipe.c b/mclient/dspipe.c
index de31fd7..7dc5e6b 100644
--- a/mclient/dspipe.c
+++ b/mclient/dspipe.c
@@ -16,6 +16,7 @@
#include <discuss/dsc_et.h>
#include <rpc.h>
#include <sys/file.h>
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
diff --git a/mclient/mkds.c b/mclient/mkds.c
index 9e668ef..98b5f0a 100644
--- a/mclient/mkds.c
+++ b/mclient/mkds.c
@@ -102,7 +102,7 @@ char *argv[];
strcpy(default_host, h);
}
printf("Meeting host: [default %s]: ", default_host);
- if (!gets(mtg_host))
+ if (!fgets(mtg_host, sizeof(mtg_host), stdin))
exit(1);
strcpy(mtg_host, strtrim(mtg_host));
if (mtg_host[0] == '\0')
@@ -119,14 +119,14 @@ char *argv[];
strcpy(mtg_host, hp->h_name);
}
printf("\nMeeting location [default %s]: ", default_dir);
- if (!gets(mtg_path))
+ if (!fgets(mtg_path, sizeof(mtg_path), stdin))
exit(1);
strcpy(mtg_path, strtrim(mtg_path));
if (!mtg_path[0])
strcpy(mtg_path, default_dir);
if (!remove) {
printf("\nLong meeting name: ");
- if (!gets(long_name))
+ if (!fgets(long_name, sizeof(long_name), stdin))
exit(1);
strcpy(long_name, strtrim(long_name));
if (long_name[0] == '\0') {
@@ -135,7 +135,7 @@ char *argv[];
}
}
printf("\nShort meeting name: ");
- if (!gets(short_name))
+ if (!fgets(short_name, sizeof(short_name), stdin))
exit(1);
strcpy(short_name, strtrim(short_name));
if(short_name[0] == '\0') {
@@ -186,7 +186,7 @@ End with . on a line by itself\n\n");
for (;;) {
printf("User name: ");
fflush(stdout);
- if (!gets(username)) break;
+ if (!fgets(username, sizeof(username), stdin)) break;
strcpy(username, strtrim(username));
if (strcmp(username, ".") == 0) break;
if (strcmp(username,"*") != 0 &&
@@ -260,7 +260,7 @@ End with . on a line by itself\n\n");
printf("\n");
for (;;) {
printf("Announce in what meeting? ");
- if (!gets(ann_mtg))
+ if (!fgets(ann_mtg, sizeof(ann_mtg), stdin))
exit(1);
dsc_get_mtg(nbsrc.user_id,strtrim(ann_mtg),
&nbdest,&result);
@@ -316,7 +316,7 @@ char *prompt,def;
for (;;) {
(void) printf("%s ",prompt);
- if (!gets(yn_inp))
+ if (!fgets(yn_inp, sizeof(yn_inp), stdin))
exit(1);
if (yn_inp[0] == '\0')
yn_inp[0] = def;
diff --git a/server/acl_core.c b/server/acl_core.c
index 7afcadf..16fecc3 100644
--- a/server/acl_core.c
+++ b/server/acl_core.c
@@ -19,6 +19,7 @@
#include "internal.h"
#include <sys/file.h>
#include <errno.h>
+#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h>
#include <string.h>
diff --git a/server/atom.c b/server/atom.c
index 73243b8..7b8a2bc 100644
--- a/server/atom.c
+++ b/server/atom.c
@@ -27,6 +27,8 @@
#include "../include/atom.h"
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
diff --git a/server/disserve.c b/server/disserve.c
index 25c2562..5bd2d39 100644
--- a/server/disserve.c
+++ b/server/disserve.c
@@ -12,6 +12,7 @@
* $Id: disserve.c,v 1.5 1999-01-22 23:10:17 ghudson Exp $
*/
+#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
extern char *error_message();
diff --git a/usp/internal.c b/usp/internal.c
index d296726..08cb2e7 100644
--- a/usp/internal.c
+++ b/usp/internal.c
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#include "gen.h"
#include "usp.h"
#include <netinet/in.h>