diff options
| author | Paul Eggert | 2011-04-16 16:11:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 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 emacs-fd35b6f96777be3305879a9ca60ab5befb254042.zip | |
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 @@ | |||
| 1 | 2011-04-16 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Static checks with GCC 4.6.0 and non-default toolkits. | ||
| 4 | |||
| 5 | * movemail.c (mail_spool_name): Protoize. | ||
| 6 | (main): Remove unused var. Mark var as initialized. | ||
| 7 | Move locals to avoid shadowing, and use time_t for times. | ||
| 8 | |||
| 9 | * fakemail.c (xmalloc, xreallc): Use standard C prototypes | ||
| 10 | with void *. This avoids warnings about pointer casts. | ||
| 11 | |||
| 12 | * emacsclient.c (main): Don't use uninitialized var. | ||
| 13 | (IS_ANY_SEP): Remove; unused. | ||
| 14 | (get_current_dir_name): Add an extern decl. | ||
| 15 | |||
| 1 | 2011-04-06 Paul Eggert <eggert@cs.ucla.edu> | 16 | 2011-04-06 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 17 | ||
| 3 | Fix more problems found by GCC 4.6.0's static checks. | 18 | 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) | |||
| 218 | #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP) | 218 | #define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP) |
| 219 | #endif | 219 | #endif |
| 220 | #endif | 220 | #endif |
| 221 | #ifndef IS_ANY_SEP | ||
| 222 | #define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_)) | ||
| 223 | #endif | ||
| 224 | 221 | ||
| 222 | char *get_current_dir_name (void); | ||
| 225 | 223 | ||
| 226 | /* Return the current working directory. Returns NULL on errors. | 224 | /* Return the current working directory. Returns NULL on errors. |
| 227 | Any other returned value must be freed with free. This is used | 225 | Any other returned value must be freed with free. This is used |
| @@ -1524,7 +1522,7 @@ start_daemon_and_retry_set_socket (void) | |||
| 1524 | int | 1522 | int |
| 1525 | main (int argc, char **argv) | 1523 | main (int argc, char **argv) |
| 1526 | { | 1524 | { |
| 1527 | int rl, needlf = 0; | 1525 | int rl = 0, needlf = 0; |
| 1528 | char *cwd, *str; | 1526 | char *cwd, *str; |
| 1529 | char string[BUFSIZ+1]; | 1527 | char string[BUFSIZ+1]; |
| 1530 | int null_socket_name IF_LINT ( = 0); | 1528 | 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) | |||
| 178 | 178 | ||
| 179 | /* Like malloc but get fatal error if memory is exhausted. */ | 179 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 180 | 180 | ||
| 181 | static long * | 181 | static void * |
| 182 | xmalloc (int size) | 182 | xmalloc (size_t size) |
| 183 | { | 183 | { |
| 184 | long *result = (long *) malloc (((unsigned) size)); | 184 | void *result = malloc (size); |
| 185 | if (result == ((long *) NULL)) | 185 | if (! result) |
| 186 | fatal ("virtual memory exhausted"); | 186 | fatal ("virtual memory exhausted"); |
| 187 | return result; | 187 | return result; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | static long * | 190 | static void * |
| 191 | xrealloc (long int *ptr, int size) | 191 | xrealloc (void *ptr, size_t size) |
| 192 | { | 192 | { |
| 193 | long *result = (long *) realloc (ptr, ((unsigned) size)); | 193 | void *result = realloc (ptr, size); |
| 194 | if (result == ((long *) NULL)) | 194 | if (! result) |
| 195 | fatal ("virtual memory exhausted"); | 195 | fatal ("virtual memory exhausted"); |
| 196 | return result; | 196 | return result; |
| 197 | } | 197 | } |
| @@ -221,7 +221,7 @@ readline (struct linebuffer *linebuffer, FILE *stream) | |||
| 221 | if (p == end) | 221 | if (p == end) |
| 222 | { | 222 | { |
| 223 | linebuffer->size *= 2; | 223 | linebuffer->size *= 2; |
| 224 | buffer = ((char *) xrealloc ((long *)buffer, linebuffer->size)); | 224 | buffer = (char *) xrealloc (buffer, linebuffer->size); |
| 225 | p = buffer + (p - linebuffer->buffer); | 225 | p = buffer + (p - linebuffer->buffer); |
| 226 | end = buffer + linebuffer->size; | 226 | end = buffer + linebuffer->size; |
| 227 | linebuffer->buffer = buffer; | 227 | 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 (); | |||
| 131 | files appear in. */ | 131 | files appear in. */ |
| 132 | #ifdef MAILDIR | 132 | #ifdef MAILDIR |
| 133 | #define MAIL_USE_MAILLOCK | 133 | #define MAIL_USE_MAILLOCK |
| 134 | static char *mail_spool_name (); | 134 | static char *mail_spool_name (char *); |
| 135 | #endif | 135 | #endif |
| 136 | #endif | 136 | #endif |
| 137 | 137 | ||
| @@ -167,7 +167,6 @@ main (int argc, char **argv) | |||
| 167 | 167 | ||
| 168 | #ifndef MAIL_USE_SYSTEM_LOCK | 168 | #ifndef MAIL_USE_SYSTEM_LOCK |
| 169 | struct stat st; | 169 | struct stat st; |
| 170 | long now; | ||
| 171 | int tem; | 170 | int tem; |
| 172 | char *lockname, *p; | 171 | char *lockname, *p; |
| 173 | char *tempname; | 172 | char *tempname; |
| @@ -259,7 +258,13 @@ main (int argc, char **argv) | |||
| 259 | #ifndef MAIL_USE_SYSTEM_LOCK | 258 | #ifndef MAIL_USE_SYSTEM_LOCK |
| 260 | #ifdef MAIL_USE_MAILLOCK | 259 | #ifdef MAIL_USE_MAILLOCK |
| 261 | spool_name = mail_spool_name (inname); | 260 | spool_name = mail_spool_name (inname); |
| 262 | if (! spool_name) | 261 | if (spool_name) |
| 262 | { | ||
| 263 | #ifdef lint | ||
| 264 | lockname = 0; | ||
| 265 | #endif | ||
| 266 | } | ||
| 267 | else | ||
| 263 | #endif | 268 | #endif |
| 264 | { | 269 | { |
| 265 | #ifndef DIRECTORY_SEP | 270 | #ifndef DIRECTORY_SEP |
| @@ -336,7 +341,7 @@ main (int argc, char **argv) | |||
| 336 | by time differences between machines. */ | 341 | by time differences between machines. */ |
| 337 | if (stat (lockname, &st) >= 0) | 342 | if (stat (lockname, &st) >= 0) |
| 338 | { | 343 | { |
| 339 | now = time (0); | 344 | time_t now = time (0); |
| 340 | if (st.st_ctime < now - 300) | 345 | if (st.st_ctime < now - 300) |
| 341 | unlink (lockname); | 346 | unlink (lockname); |
| 342 | } | 347 | } |
| @@ -352,7 +357,10 @@ main (int argc, char **argv) | |||
| 352 | int lockcount = 0; | 357 | int lockcount = 0; |
| 353 | int status = 0; | 358 | int status = 0; |
| 354 | #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) | 359 | #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) |
| 355 | time_t touched_lock, now; | 360 | time_t touched_lock; |
| 361 | # ifdef lint | ||
| 362 | touched_lock = 0; | ||
| 363 | # endif | ||
| 356 | #endif | 364 | #endif |
| 357 | 365 | ||
| 358 | if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0) | 366 | if (setuid (getuid ()) < 0 || setregid (-1, real_gid) < 0) |
| @@ -462,7 +470,7 @@ main (int argc, char **argv) | |||
| 462 | #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) | 470 | #if defined (MAIL_USE_MAILLOCK) && defined (HAVE_TOUCHLOCK) |
| 463 | if (spool_name) | 471 | if (spool_name) |
| 464 | { | 472 | { |
| 465 | now = time (0); | 473 | time_t now = time (0); |
| 466 | if (now - touched_lock > 60) | 474 | if (now - touched_lock > 60) |
| 467 | { | 475 | { |
| 468 | touchlock (); | 476 | touchlock (); |