Remove all occurrences of the bad_cast (lowercase) function.

Not to be confused with the libxml2 macro 'BAD_CAST' which converts
from 'signed char *' to 'unsigned char *'.

The 'bad_cast' function was defined and used all over the place as a
replacement for a '(char *)' cast.  I think it is better to make these
casts explicit, instead of hiding them in an obscure function.
This commit is contained in:
Richard W.M. Jones
2013-02-01 14:16:51 +00:00
parent ec3b75e5ff
commit 42bffcd00a
18 changed files with 15 additions and 119 deletions

View File

@@ -53,12 +53,6 @@ int inspector = 0;
static int quiet = 0; /* --quiet */
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -130,7 +124,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -48,12 +48,6 @@ int inspector = 1;
static int is_windows (guestfs_h *g, const char *root);
static char *windows_path (guestfs_h *g, const char *root, const char *filename);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -122,7 +116,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -80,12 +80,6 @@ static void do_output_end (void);
static struct guestfs_lvm_pv_list *get_pvs (void);
static void free_pvs (void);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -197,7 +191,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -84,12 +84,6 @@ static int is_sock (int64_t mode);
static void free_strings (char **);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -191,7 +185,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -59,12 +59,6 @@ int uuid = 0; /* --uuid */
static char *make_display_name (struct drv *drvs);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -139,7 +133,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -62,12 +62,6 @@ static char *windows_path (guestfs_h *g, const char *root, const char *filename)
static char *generate_random_name (const char *filename);
static char *generate_backup_name (const char *filename);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -144,7 +138,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -222,7 +222,7 @@ run_delete_event (const char *cmd, size_t argc, char *argv[])
return -1;
}
const struct entry key = { .name = bad_cast (argv[0]) };
const struct entry key = { .name = argv[0] };
struct entry *entry, *p;
entry = hash_delete (event_handlers, &key);

View File

@@ -242,7 +242,7 @@ main (int argc, char *argv[])
* of the original, in case it's needed below.
*/
//char *real_argv0 = argv[0];
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -116,10 +116,4 @@ extern char *try_tilde_expansion (char *path);
"help", \
"quit", "exit", "q"
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
#endif /* FISH_H */

View File

@@ -146,7 +146,7 @@ extern int add_libvirt_drives (const char *guest);
exit (EXIT_FAILURE); \
} \
mp->options = NULL; \
mp->mountpoint = bad_cast ("/"); \
mp->mountpoint = (char *) "/"; \
p = strchr (optarg, ':'); \
if (p) { \
*p = '\0'; \

View File

@@ -117,7 +117,7 @@ Use 'guestfish -N help' to list possible values for the -N parameter.\n"),
}
for (i = 0; i < data->prep->nr_params; ++i)
data->params[i] = bad_cast (data->prep->params[i].pdefault);
data->params[i] = (char *) data->prep->params[i].pdefault;
/* Parse the optional parameters. */
const char *p = type_string + len;

View File

@@ -56,12 +56,6 @@ static int do_format (void);
static int do_rescan (char **devices);
static int feature_available (guestfs_h *g, const char *feature);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -138,7 +132,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -37,8 +37,7 @@ SHARED_SOURCE_FILES = \
guestmount_SOURCES = \
$(SHARED_SOURCE_FILES) \
guestmount.c \
guestmount.h
guestmount.c
guestmount_CFLAGS = \
-DGUESTFS_WARN_DEPRECATED=1 \

View File

@@ -39,7 +39,6 @@
#include "progname.h"
#include "ignore-value.h"
#include "guestmount.h"
#include "options.h"
static int write_pid_file (const char *pid_file, pid_t pid);

View File

@@ -1,36 +0,0 @@
/* guestmount - mount guests using libguestfs and FUSE
* Copyright (C) 2009 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Derived from the example program 'fusexmp.c':
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
* This program can be distributed under the terms of the GNU GPL.
* See the file COPYING.
*/
#ifndef GUESTMOUNT_H_
#define GUESTMOUNT_H_
#include "guestfs-internal-frontend.h"
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
#endif /* GUESTMOUNT_H_ */

View File

@@ -63,12 +63,6 @@ static void free_strings (char **argv);
static size_t count_strings (char *const*argv);
static void do_xpath (const char *query);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -139,7 +133,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -50,12 +50,6 @@ int echo_keys = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -147,7 +141,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);

View File

@@ -86,19 +86,13 @@ guestfs_set_private (guestfs_h *g, const char *key, void *data)
assert (entry == new_entry);
}
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
void *
guestfs_get_private (guestfs_h *g, const char *key)
{
if (g->pda == NULL)
return NULL; /* no keys have been set */
const struct pda_entry k = { .key = bad_cast (key) };
const struct pda_entry k = { .key = (char *) key };
struct pda_entry *entry = hash_lookup (g->pda, &k);
if (entry)
return entry->data;