[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103424: Merge: lib-src changes mostl
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103424: Merge: lib-src changes mostly to avoid GCC warnings |
Date: |
Fri, 25 Feb 2011 21:54:36 -0800 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103424 [merge]
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2011-02-25 21:54:36 -0800
message:
Merge: lib-src changes mostly to avoid GCC warnings
modified:
lib-src/ChangeLog
lib-src/ebrowse.c
lib-src/emacsclient.c
lib-src/etags.c
lib-src/fakemail.c
lib-src/make-docfile.c
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2011-02-23 15:22:28 +0000
+++ b/lib-src/ChangeLog 2011-02-26 05:43:51 +0000
@@ -1,3 +1,49 @@
+2011-02-26 Paul Eggert <address@hidden>
+
+ * ebrowse.c (parse_qualified_param_ident_or_type): Make it clear
+ to reader (and to the compiler) that the loop always executes at
+ least once. This prevents a warning with recent GCC.
+ (BROWSE_STRUCT): Remove unused macro.
+
+ * fakemail.c: Include <ignore-value.h>.
+ (put_line): Explicitly ignore fwrite return value, for benefit of
+ recent glibc + gcc.
+ (close_the_streams): Diagnose output errors instead of merely
+ exiting with nonzero status.
+ (my_fclose, main): Diagnose input errors, and exit with nonzero status.
+ Formerly, input errors were silently ignored.
+
+ * ebrowse.c (putstr): Rename from PUTSTR and turn into a function.
+ All callers changed. This is cleaner, and avoids GCC warnings about
+ passing NULL to fputs.
+ (insert_keyword): Rename parameter to avoid shadowing diagnostic.
+
+2011-02-25 Paul Eggert <address@hidden>
+
+ * emacsclient.c (main): Avoid dangling 'if'.
+ (xstrdup): Remove; no longer needed.
+ (get_current_dir_name, w32_getenv, get_server_config, find_tty):
+ (set_local_socket, main):
+ Use const char *, not char *, for pointers that are not assigned
+ through.
+ (IF_LINT): New macro.
+ (set_local_socket, main): Use it to suppress warnings with
+ GCC -Wuninitialized.
+
+ * emacsclient.c: Redo local variables to avoid shadowing problems.
+ (message, socket_status, start_daemon_and_retry_set_socket):
+ Rename locals.
+ (main): Move decl of "i".
+
+ * etags.c (ISUPPER): Move to inside the only #ifdef where it's used.
+ This avoids an unused-macro warning with some GCC settings.
+
+ * make-docfile.c (write_globals): Change char * to char const *
+ to avoid a GCC "assignment discards qualifiers" diagnostic
+ in some configurations.
+ (scan_c_file): Refactor local variable decls to make their scope
+ more accurate and to avoid a GCC -Wuninitialized diagnostic.
+
2011-02-22 Eli Zaretskii <address@hidden>
* etags.c (canonicalize_filename, ISUPPER): Fix last change.
=== modified file 'lib-src/ebrowse.c'
--- a/lib-src/ebrowse.c 2011-02-21 23:22:34 +0000
+++ b/lib-src/ebrowse.c 2011-02-26 05:43:51 +0000
@@ -77,7 +77,6 @@
#define TREE_HEADER_STRUCT "[ebrowse-hs "
#define TREE_STRUCT "[ebrowse-ts "
#define MEMBER_STRUCT "[ebrowse-ms "
-#define BROWSE_STRUCT "[ebrowse-bs "
#define CLASS_STRUCT "[ebrowse-cs "
/* The name of the symbol table entry for global functions, variables,
@@ -1108,22 +1107,23 @@
/* Write string S to the output file FP in a Lisp-readable form.
If S is null, write out `()'. */
-#define PUTSTR(s, fp) \
- do { \
- if (!s) \
- { \
- putc ('(', fp); \
- putc (')', fp); \
- putc (' ', fp); \
- } \
- else \
- { \
- putc ('"', fp); \
- fputs (s, fp); \
- putc ('"', fp); \
- putc (' ', fp); \
- } \
- } while (0)
+static inline void
+putstr (const char *s, FILE *fp)
+{
+ if (!s)
+ {
+ putc ('(', fp);
+ putc (')', fp);
+ putc (' ', fp);
+ }
+ else
+ {
+ putc ('"', fp);
+ fputs (s, fp);
+ putc ('"', fp);
+ putc (' ', fp);
+ }
+}
/* A dynamically allocated buffer for constructing a scope name. */
@@ -1216,16 +1216,16 @@
for (n = 0; m; m = m->next, ++n)
{
fputs (MEMBER_STRUCT, fp);
- PUTSTR (m->name, fp);
- PUTSTR (NULL, fp); /* FIXME? scope for globals */
+ putstr (m->name, fp);
+ putstr (NULL, fp); /* FIXME? scope for globals */
fprintf (fp, "%u ", (unsigned) m->flags);
- PUTSTR (m->filename, fp);
- PUTSTR (m->regexp, fp);
+ putstr (m->filename, fp);
+ putstr (m->regexp, fp);
fprintf (fp, "%u ", (unsigned) m->pos);
fprintf (fp, "%u ", (unsigned) m->vis);
putc (' ', fp);
- PUTSTR (m->def_filename, fp);
- PUTSTR (m->def_regexp, fp);
+ putstr (m->def_filename, fp);
+ putstr (m->def_regexp, fp);
fprintf (fp, "%u", (unsigned) m->def_pos);
putc (']', fp);
putc ('\n', fp);
@@ -1243,20 +1243,20 @@
dump_sym (FILE *fp, struct sym *root)
{
fputs (CLASS_STRUCT, fp);
- PUTSTR (root->name, fp);
+ putstr (root->name, fp);
/* Print scope, if any. */
if (root->namesp)
- PUTSTR (sym_scope (root), fp);
+ putstr (sym_scope (root), fp);
else
- PUTSTR (NULL, fp);
+ putstr (NULL, fp);
/* Print flags. */
fprintf (fp, "%u", root->flags);
- PUTSTR (root->filename, fp);
- PUTSTR (root->regexp, fp);
+ putstr (root->filename, fp);
+ putstr (root->regexp, fp);
fprintf (fp, "%u", (unsigned) root->pos);
- PUTSTR (root->sfilename, fp);
+ putstr (root->sfilename, fp);
putc (']', fp);
putc ('\n', fp);
}
@@ -1323,7 +1323,7 @@
if (!f_append)
{
fputs (TREE_HEADER_STRUCT, fp);
- PUTSTR (EBROWSE_FILE_VERSION, fp);
+ putstr (EBROWSE_FILE_VERSION, fp);
putc ('\"', fp);
if (!f_structs)
@@ -2062,11 +2062,11 @@
}
-/* Insert a keyword NAME with token value TK into the keyword hash
+/* Insert a keyword NAME with token value TKV into the keyword hash
table. */
static void
-insert_keyword (const char *name, int tk)
+insert_keyword (const char *name, int tkv)
{
const char *s;
unsigned h = 0;
@@ -2077,7 +2077,7 @@
h %= KEYWORD_TABLE_SIZE;
k->name = name;
- k->tk = tk;
+ k->tk = tkv;
k->next = keyword_table[h];
keyword_table[h] = k;
}
@@ -2951,7 +2951,9 @@
static char *id = NULL;
static int id_size = 0;
- while (LOOKING_AT (IDENT))
+ assert (LOOKING_AT (IDENT));
+
+ do
{
int len = strlen (yytext) + 1;
if (len > id_size)
@@ -2974,6 +2976,7 @@
else
break;
}
+ while (LOOKING_AT (IDENT));
}
=== modified file 'lib-src/emacsclient.c'
--- a/lib-src/emacsclient.c 2011-02-21 18:06:25 +0000
+++ b/lib-src/emacsclient.c 2011-02-26 00:17:02 +0000
@@ -112,6 +112,13 @@
/* Additional space when allocating buffers for filenames, etc. */
#define EXTRA_SPACE 100
+/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
/* Name used to invoke this program. */
const char *progname;
@@ -190,20 +197,6 @@
return result;
}
-/* Like strdup but get a fatal error if memory is exhausted. */
-
-static char *
-xstrdup (const char *s)
-{
- char *result = strdup (s);
- if (result == NULL)
- {
- perror ("strdup");
- exit (EXIT_FAILURE);
- }
- return result;
-}
-
/* From sysdep.c */
#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined
(BROKEN_GET_CURRENT_DIR_NAME)
@@ -233,7 +226,7 @@
get_current_dir_name (void)
{
char *buf;
- char *pwd;
+ const char *pwd;
struct stat dotstat, pwdstat;
/* If PWD is accurate, use it instead of calling getwd. PWD is
sometimes a nicer name, and using it may avoid a fatal error if a
@@ -353,7 +346,7 @@
{
/* "w32console" is what Emacs on Windows uses for tty-type under -nw. */
if (strcmp (envvar, "TERM") == 0)
- return xstrdup ("w32console");
+ return "w32console";
/* Found neither in the environment nor in the registry. */
return NULL;
}
@@ -474,13 +467,13 @@
/* Display a normal or error message.
On Windows, use a message box if compiled as a Windows app. */
static void
-message (int is_error, const char *message, ...)
+message (int is_error, const char *format, ...)
{
char msg[2048];
va_list args;
- va_start (args, message);
- vsprintf (msg, message, args);
+ va_start (args, format);
+ vsprintf (msg, format, args);
va_end (args);
#ifdef WINDOWSNT
@@ -918,7 +911,7 @@
config = fopen (server_file, "rb");
else
{
- char *home = egetenv ("HOME");
+ const char *home = egetenv ("HOME");
if (home)
{
@@ -1025,10 +1018,10 @@
is zero, or return 0 if NOABORT is non-zero. */
static int
-find_tty (char **tty_type, char **tty_name, int noabort)
+find_tty (const char **tty_type, const char **tty_name, int noabort)
{
- char *type = egetenv ("TERM");
- char *name = ttyname (fileno (stdout));
+ const char *type = egetenv ("TERM");
+ const char *name = ttyname (fileno (stdout));
if (!name)
{
@@ -1080,11 +1073,11 @@
0 - success: none of the above */
static int
-socket_status (char *socket_name)
+socket_status (char *name)
{
struct stat statbfr;
- if (stat (socket_name, &statbfr) == -1)
+ if (stat (name, &statbfr) == -1)
return 2;
if (statbfr.st_uid != geteuid ())
@@ -1205,7 +1198,7 @@
int default_sock = !socket_name;
int saved_errno = 0;
const char *server_name = "server";
- const char *tmpdir;
+ const char *tmpdir IF_LINT ( = NULL);
if (socket_name && !strchr (socket_name, '/')
&& !strchr (socket_name, '\\'))
@@ -1260,10 +1253,10 @@
associated with the name. This is reminiscent of the logic
that init_editfns uses to set the global Vuser_full_name. */
- char *user_name = (char *) egetenv ("LOGNAME");
+ const char *user_name = egetenv ("LOGNAME");
if (!user_name)
- user_name = (char *) egetenv ("USER");
+ user_name = egetenv ("USER");
if (user_name)
{
@@ -1483,8 +1476,8 @@
else
{
char emacs[] = "emacs";
- char daemon[] = "--daemon";
- char *d_argv[] = {emacs, daemon, 0 };
+ char daemon_option[] = "--daemon";
+ char *d_argv[] = {emacs, daemon_option, 0 };
if (socket_name != NULL)
{
/* Pass --daemon=socket_name as argument. */
@@ -1504,10 +1497,12 @@
int
main (int argc, char **argv)
{
- int i, rl, needlf = 0;
+ int rl, needlf = 0;
char *cwd, *str;
char string[BUFSIZ+1];
- int null_socket_name, null_server_file, start_daemon_if_needed;
+ int null_socket_name IF_LINT ( = 0);
+ int null_server_file IF_LINT ( = 0);
+ int start_daemon_if_needed;
int exit_status = EXIT_SUCCESS;
main_argv = argv;
@@ -1543,21 +1538,21 @@
null_server_file = (server_file == NULL);
}
- if ((emacs_socket = set_socket (alternate_editor
- || start_daemon_if_needed)) == INVALID_SOCKET)
- if (start_daemon_if_needed)
- {
- /* Reset socket_name and server_file if they were NULL
- before the set_socket call. */
- if (null_socket_name)
- socket_name = NULL;
- if (null_server_file)
- server_file = NULL;
-
- start_daemon_and_retry_set_socket ();
- }
- else
- fail ();
+ emacs_socket = set_socket (alternate_editor || start_daemon_if_needed);
+ if (emacs_socket == INVALID_SOCKET)
+ {
+ if (! start_daemon_if_needed)
+ fail ();
+
+ /* Reset socket_name and server_file if they were NULL
+ before the set_socket call. */
+ if (null_socket_name)
+ socket_name = NULL;
+ if (null_server_file)
+ server_file = NULL;
+
+ start_daemon_and_retry_set_socket ();
+ }
cwd = get_current_dir_name ();
if (cwd == 0)
@@ -1615,7 +1610,7 @@
frame is available. */
if (tty || (current_frame && !eval))
{
- char *tty_type, *tty_name;
+ const char *tty_type, *tty_name;
if (find_tty (&tty_type, &tty_name, !tty))
{
@@ -1635,6 +1630,7 @@
if ((argc - optind > 0))
{
+ int i;
for (i = optind; i < argc; i++)
{
=== modified file 'lib-src/etags.c'
--- a/lib-src/etags.c 2011-02-22 18:08:53 +0000
+++ b/lib-src/etags.c 2011-02-25 23:26:55 +0000
@@ -236,7 +236,6 @@
#define ISALNUM(c) isalnum (CHAR(c))
#define ISALPHA(c) isalpha (CHAR(c))
#define ISDIGIT(c) isdigit (CHAR(c))
-#define ISUPPER(c) isupper (CHAR(c))
#define ISLOWER(c) islower (CHAR(c))
#define lowcase(c) tolower (CHAR(c))
@@ -6648,6 +6647,7 @@
#ifdef DOS_NT
/* Canonicalize drive letter case. */
+# define ISUPPER(c) isupper (CHAR(c))
if (fn[0] != '\0' && fn[1] == ':' && ISUPPER (fn[0]))
fn[0] = lowcase (fn[0]);
=== modified file 'lib-src/fakemail.c'
--- a/lib-src/fakemail.c 2011-02-21 18:06:25 +0000
+++ b/lib-src/fakemail.c 2011-02-26 05:36:51 +0000
@@ -62,6 +62,8 @@
/* This is to declare cuserid. */
#include <unistd.h>
+
+#include <ignore-value.h>
/* Type definitions */
@@ -405,8 +407,8 @@
for (rem = the_streams;
rem != ((stream_list) NULL);
rem = rem->rest_streams)
- no_problems = (no_problems &&
- ((*rem->action) (rem->handle) == 0));
+ if (no_problems && (*rem->action) (rem->handle) != 0)
+ error ("output error", NULL);
the_streams = ((stream_list) NULL);
return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -427,6 +429,8 @@
{
putc ('\n', the_file);
fflush (the_file);
+ if (ferror (the_file))
+ return EOF;
return fclose (the_file);
}
@@ -496,7 +500,7 @@
}
}
/* Output that much, then break the line. */
- fwrite (s, 1, breakpos - s, rem->handle);
+ ignore_value (fwrite (s, 1, breakpos - s, rem->handle));
column = 8;
/* Skip whitespace and prepare to print more addresses. */
@@ -729,6 +733,9 @@
put_string (buf);
}
+ if (no_problems && (ferror (stdin) || fclose (stdin) != 0))
+ error ("input error", NULL);
+
exit (close_the_streams ());
}
=== modified file 'lib-src/make-docfile.c'
--- a/lib-src/make-docfile.c 2011-02-21 19:37:54 +0000
+++ b/lib-src/make-docfile.c 2011-02-25 22:21:01 +0000
@@ -617,7 +617,7 @@
qsort (globals, num_globals, sizeof (struct global), compare_globals);
for (i = 0; i < num_globals; ++i)
{
- char *type;
+ char const *type;
switch (globals[i].type)
{
@@ -658,12 +658,8 @@
FILE *infile;
register int c;
register int commas;
- register int defunflag;
- register int defvarperbufferflag;
- register int defvarflag;
int minargs, maxargs;
int extension = filename[strlen (filename) - 1];
- enum global_type type;
if (extension == 'o')
filename[strlen (filename) - 1] = 'c';
@@ -693,6 +689,10 @@
while (!feof (infile))
{
int doc_keyword = 0;
+ int defunflag = 0;
+ int defvarperbufferflag = 0;
+ int defvarflag = 0;
+ enum global_type type = INVALID;
if (c != '\n' && c != '\r')
{
@@ -726,7 +726,6 @@
continue;
defvarflag = 1;
- defunflag = 0;
c = getc (infile);
defvarperbufferflag = (c == 'P');
@@ -738,8 +737,6 @@
type = LISP_OBJECT;
else if (c == 'B')
type = BOOLEAN;
- else
- type = INVALID;
}
c = getc (infile);
@@ -758,8 +755,6 @@
continue;
c = getc (infile);
defunflag = c == 'U';
- defvarflag = 0;
- defvarperbufferflag = 0;
}
else continue;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103424: Merge: lib-src changes mostly to avoid GCC warnings,
Paul Eggert <=