Clean up GCC warnings.

* src/reader.c (copy_action): `buf' is not used.
(parse_skel_decl): Be static.
* src/muscle_tab.c (mhash1, mhash2, muscle_insert): Preserve `const'.
* src/options.h (create_long_option_table): Have a real prototype.
* lib/hash.c, lib/hash.h (hash_insert, hash_insert_at, hash_delete)
(hash_delete_at): Return const void *.
Adjust casts to preserve the const.
This commit is contained in:
Akim Demaille
2001-12-10 09:05:47 +00:00
parent 75addd5e5f
commit a870c5670e
6 changed files with 36 additions and 23 deletions

View File

@@ -1,3 +1,15 @@
2001-12-10 Akim Demaille <akim@epita.fr>
Clean up GCC warnings.
* src/reader.c (copy_action): `buf' is not used.
(parse_skel_decl): Be static.
* src/muscle_tab.c (mhash1, mhash2, muscle_insert): Preserve `const'.
* src/options.h (create_long_option_table): Have a real prototype.
* lib/hash.c, lib/hash.h (hash_insert, hash_insert_at, hash_delete)
(hash_delete_at): Return const void *.
Adjust casts to preserve the const.
2001-12-10 Akim Demaille <akim@epita.fr> 2001-12-10 Akim Demaille <akim@epita.fr>
* configure.in: Require 2.52g. * configure.in: Require 2.52g.

View File

@@ -1,5 +1,5 @@
/* hash.c -- hash table maintenance /* hash.c -- hash table maintenance
Copyright (C) 1995 Free Software Foundation, Inc. Copyright 1995, 2001 Free Software Foundation, Inc.
Written by Greg McGary <gkm@gnu.ai.mit.edu> Written by Greg McGary <gkm@gnu.ai.mit.edu>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -120,17 +120,17 @@ hash_find_item (struct hash_table* ht, void const *key)
return ((HASH_VACANT (*slot)) ? 0 : *slot); return ((HASH_VACANT (*slot)) ? 0 : *slot);
} }
void * const void *
hash_insert (struct hash_table* ht, void *item) hash_insert (struct hash_table* ht, void *item)
{ {
void **slot = hash_find_slot (ht, item); void **slot = hash_find_slot (ht, item);
return hash_insert_at (ht, item, slot); return hash_insert_at (ht, item, slot);
} }
void * const void *
hash_insert_at (struct hash_table* ht, void *item, void const *slot) hash_insert_at (struct hash_table* ht, void *item, void const *slot)
{ {
void *old_item = *(void **) slot; const void *old_item = *(const void **) slot;
if (HASH_VACANT (old_item)) if (HASH_VACANT (old_item))
{ {
ht->ht_fill++; ht->ht_fill++;
@@ -142,17 +142,17 @@ hash_insert_at (struct hash_table* ht, void *item, void const *slot)
return old_item; return old_item;
} }
void * const void *
hash_delete (struct hash_table* ht, void const *item) hash_delete (struct hash_table* ht, void const *item)
{ {
void **slot = hash_find_slot (ht, item); void **slot = hash_find_slot (ht, item);
return hash_delete_at (ht, slot); return hash_delete_at (ht, slot);
} }
void * const void *
hash_delete_at (struct hash_table* ht, void const *slot) hash_delete_at (struct hash_table* ht, void const *slot)
{ {
void *item = *(void **) slot; const void *item = *(const void **) slot;
if (!HASH_VACANT (item)) if (!HASH_VACANT (item))
{ {
*(void const **) slot = hash_deleted_item; *(void const **) slot = hash_deleted_item;

View File

@@ -1,5 +1,5 @@
/* hash.h -- decls for hash table /* hash.h -- decls for hash table
Copyright (C) 1995 Free Software Foundation, Inc. Copyright 1995, 2001 Free Software Foundation, Inc.
Written by Greg McGary <gkm@gnu.ai.mit.edu> Written by Greg McGary <gkm@gnu.ai.mit.edu>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@@ -47,10 +47,10 @@ void hash_load __P((struct hash_table *ht, void *item_table,
unsigned long cardinality, unsigned long size)); unsigned long cardinality, unsigned long size));
void **hash_find_slot __P((struct hash_table *ht, void const *key)); void **hash_find_slot __P((struct hash_table *ht, void const *key));
void *hash_find_item __P((struct hash_table *ht, void const *key)); void *hash_find_item __P((struct hash_table *ht, void const *key));
void *hash_insert __P((struct hash_table *ht, void *item)); const void *hash_insert __P((struct hash_table *ht, void *item));
void *hash_insert_at __P((struct hash_table *ht, void *item, void const *slot)); const void *hash_insert_at __P((struct hash_table *ht, void *item, void const *slot));
void *hash_delete __P((struct hash_table *ht, void const *item)); const void *hash_delete __P((struct hash_table *ht, void const *item));
void *hash_delete_at __P((struct hash_table *ht, void const *slot)); const void *hash_delete_at __P((struct hash_table *ht, void const *slot));
void hash_delete_items __P((struct hash_table *ht)); void hash_delete_items __P((struct hash_table *ht));
void hash_free_items __P((struct hash_table *ht)); void hash_free_items __P((struct hash_table *ht));
void hash_free __P((struct hash_table *ht, int free_items)); void hash_free __P((struct hash_table *ht, int free_items));
@@ -59,7 +59,8 @@ void hash_print_stats __P((struct hash_table *ht, FILE *out_FILE));
void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compare)); void **hash_dump __P((struct hash_table *ht, void **vector_0, qsort_cmp_t compare));
extern void *hash_deleted_item; extern void *hash_deleted_item;
#define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item) #define HASH_VACANT(item) \
((item) == 0 || (const void *) (item) == hash_deleted_item)
/* hash and comparison macros for string keys. */ /* hash and comparison macros for string keys. */

View File

@@ -1,5 +1,5 @@
/* Macro table manager for Bison, /* Macro table manager for Bison,
Copyright 1984, 1989, 2000 Free Software Foundation, Inc. Copyright 2001 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -32,19 +32,20 @@ struct hash_table muscle_table;
static unsigned long static unsigned long
mhash1 (const void *item) mhash1 (const void *item)
{ {
return_STRING_HASH_1 (((muscle_entry_t *) item)->key); return_STRING_HASH_1 (((const muscle_entry_t *) item)->key);
} }
static unsigned long static unsigned long
mhash2 (const void *item) mhash2 (const void *item)
{ {
return_STRING_HASH_2 (((muscle_entry_t *) item)->key); return_STRING_HASH_2 (((const muscle_entry_t *) item)->key);
} }
static int static int
mcmp (const void *x, const void *y) mcmp (const void *x, const void *y)
{ {
return strcmp (((muscle_entry_t*) x)->key, ((muscle_entry_t *) y)->key); return strcmp (((const muscle_entry_t*) x)->key,
((const muscle_entry_t *) y)->key);
} }
void void
@@ -105,7 +106,7 @@ muscle_init (void)
muscle_insert ("name", "Parser"); muscle_insert ("name", "Parser");
} }
void void
muscle_insert (const char *key, const char *value) muscle_insert (const char *key, const char *value)
{ {
muscle_entry_t *pair = XMALLOC (muscle_entry_t, 1); muscle_entry_t *pair = XMALLOC (muscle_entry_t, 1);

View File

@@ -57,6 +57,6 @@ extern struct option *longopts;
extern const struct option_table_struct option_table[]; extern const struct option_table_struct option_table[];
/* Set the longopts variable from option_table. */ /* Set the longopts variable from option_table. */
void create_long_option_table PARAMS (()); void create_long_option_table PARAMS ((void));
#endif /* !OPTIONS_H_ */ #endif /* !OPTIONS_H_ */

View File

@@ -966,7 +966,7 @@ parse_muscle_decl (void)
/*---------------------------------. /*---------------------------------.
| Parse a double quoted parameter. | | Parse a double quoted parameter. |
`---------------------------------*/ `---------------------------------*/
static const char * static const char *
@@ -994,7 +994,7 @@ parse_dquoted_param (const char *from)
else else
break; break;
} }
obstack_1grow (&param_obstack, '\0'); obstack_1grow (&param_obstack, '\0');
param = obstack_finish (&param_obstack); param = obstack_finish (&param_obstack);
@@ -1014,7 +1014,7 @@ parse_dquoted_param (const char *from)
| Parse what comes after %skeleton. | | Parse what comes after %skeleton. |
`----------------------------------*/ `----------------------------------*/
void static void
parse_skel_decl (void) parse_skel_decl (void)
{ {
skeleton = parse_dquoted_param ("%skeleton"); skeleton = parse_dquoted_param ("%skeleton");
@@ -1133,7 +1133,6 @@ copy_action (symbol_list *rule, int stack_offset)
{ {
int c; int c;
int count; int count;
char buf[4096];
/* offset is always 0 if parser has already popped the stack pointer */ /* offset is always 0 if parser has already popped the stack pointer */
if (semantic_parser) if (semantic_parser)