diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-16 16:11:35 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-04-16 16:11:35 -0700 |
| commit | fd35b6f96777be3305879a9ca60ab5befb254042 (patch) | |
| tree | db72c649acdc7f53d9672fba88b6a08b3601cdda /lib-src | |
| parent | c4354cb4f4a3982331180439120ca72734d49cc5 (diff) | |
| parent | 399c71d323b8beef139437311c78440d0033c652 (diff) | |
| download | emacs-fd35b6f96777be3305879a9ca60ab5befb254042.tar.gz | |
Static checks with GCC 4.6.0 and non-default toolkits.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 15 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 6 | ||||
| -rw-r--r-- | lib-src/fakemail.c | 18 | ||||
| -rw-r--r-- | lib-src/movemail.c | 20 |
4 files changed, 40 insertions, 19 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index e3d7edf94bd..c45da107a8c 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,18 @@ +2011-04-16 Paul Eggert <eggert@cs.ucla.edu> + + Static checks with GCC 4.6.0 and non-default toolkits. + + * movemail.c (mail_spool_name): Protoize. + (main): Remove unused var. Mark var as initialized. + Move locals to avoid shadowing, and use time_t for times. + + * fakemail.c (xmalloc, xreallc): Use standard C prototypes + with void *. This avoids warnings about pointer casts. + + * emacsclient.c (main): Don't use uninitialized var. + (IS_ANY_SEP): Remove; unused. + (get_current_dir_name): Add an extern decl. + 2011-04-06 Paul Eggert <eggert@cs.ucla.edu> Fix more problems found by GCC 4.6.0's static checks. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index c5231fb9989..2aabc52e828 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -218,10 +218,8 @@ xmalloc (unsigned int size) #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP) #endif #endif -#ifndef IS_ANY_SEP -#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_)) -#endif +char *get_current_dir_name (void); /* Return the current working directory. Returns NULL on errors. Any other returned value must be freed with free. This is used @@ -1524,7 +1522,7 @@ start_daemon_and_retry_set_socket (void) int main (int argc, char **argv) { - int rl, needlf = 0; + int rl = 0, needlf = 0; char *cwd, *str; char string[BUFSIZ+1]; int null_socket_name IF_LINT ( = 0); diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 940d6219425..435512125ff 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -178,20 +178,20 @@ fatal (const char *s1) /* Like malloc but get fatal error if memory is exhausted. */ -static long * -xmalloc (int size) +static void * +xmalloc (size_t size) { - long *result = (long *) malloc (((unsigned) size)); - if (result == ((long *) NULL)) + void *result = malloc (size); + if (! result) fatal ("virtual memory exhausted"); return result; } -static long * -xrealloc (long int *ptr, int size) +static void * +xrealloc (void *ptr, size_t size) { - long *result = (long *) realloc (ptr, ((unsigned) size)); - if (result == ((long *) NULL)) + void *result = realloc (ptr, size); + if (! result) fatal ("virtual memory exhausted"); return result; } @@ -221,7 +221,7 @@ readline (struct linebuffer *linebuffer, FILE *stream) if (p == end) { linebuffer->size *= 2; - buffer = ((char *) xrealloc ((long *)buffer, linebuffer->size)); + buffer = (char *) xrealloc (buffer, linebuffer->size); p = buffer + (p - linebuffer->buffer); end = buffer + linebuffer->size; linebuffer->buffer = buffer; diff --git a/lib-src/movemail.c b/lib-src/movemail.c index 4a894c1cba1..4cf97cbac18 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -131,7 +131,7 @@ extern int lk_open (), lk_close (); files appear in. */ #ifdef MAILDIR #define MAIL_USE_MAILLOCK -static char *mail_spool_name (); +static char *mail_spool_name (char *); #endif #endif @@ -167,7 +167,6 @@ main (int argc, char **argv) #ifndef MAIL_USE_SYSTEM_LOCK struct stat st; - long now; int tem; char *lockname, *p; char *tempname; @@ -259,7 +258,13 @@ main (int argc, char **argv) #ifndef MAIL_USE_SYSTEM_LOCK #ifdef MAIL_USE_MAILLOCK spool_name = mail_spool_name (inname); - if (! spool_name) + if (spool_name) + { +#ifdef lint + lockname = 0; +#endif + } + else #endif { #ifndef DIRECTORY_SEP @@ -336,7 +341,7 @@ main (int argc, char **argv) by time differences between machines. */ if (stat (lockname, &st) >= 0) { - now = time (0); + time_t now = time (0); if (st.st_ctime < now - 300) unlink (lockname); } @@ -352,7 +357,10 @@ main (int argc, char **argv) int lockcount = 0; int status = 0; #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) - time_t touched_lock, now; + time_t touched_lock; +# ifdef lint + touched_lock = 0; +# endif #endif if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0) @@ -462,7 +470,7 @@ main (int argc, char **argv) #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) if (spool_name) { - now = time (0); + time_t now = time (0); if (now - touched_lock > 60) { touchlock (); |
