Mark variables and constant as static in source tools, examples and tests. Also replace some char pointers with char arrays.

This commit is contained in:
flameeyes
2008-06-19 15:44:10 +00:00
parent 5d2dc434e3
commit 3685c0d78e
13 changed files with 129 additions and 136 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-drive.c,v 1.28 2008/04/14 17:30:26 karl Exp $
$Id: cd-drive.c,v 1.29 2008/06/19 15:44:10 flameeyes Exp $
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
@@ -31,7 +31,7 @@
/* Used by `main' to communicate with `parse_opt'. And global options
*/
struct arguments
static struct arguments
{
uint32_t debug_level;
int version_only;
@@ -58,7 +58,7 @@ parse_options (int argc, char *argv[])
{
int opt;
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" -d, --debug=INT Set debugging to LEVEL\n"
" -i, --cdrom-device[=DEVICE] show only info about CD-ROM device\n"
@@ -70,12 +70,12 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-d|--debug INT] [-i|--cdrom-device DEVICE] [-q|--quiet]\n"
" [-V|--version] [-?|--help] [--usage]\n";
const char* optionsString = "d:i::qV?";
struct option optionsTable[] = {
static const char optionsString[] = "d:i::qV?";
static const struct option optionsTable[] = {
{"debug", required_argument, NULL, 'd' },
{"cdrom-device", optional_argument, NULL, 'i' },
{"quiet", no_argument, NULL, 'q' },

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-info.c,v 1.153 2008/04/14 17:30:26 karl Exp $
$Id: cd-info.c,v 1.154 2008/06/19 15:44:12 flameeyes Exp $
Copyright (C) 2003, 2004, 2005, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -64,13 +64,13 @@
#define NORMAL ""
#if CDIO_IOCTL_FINISHED
struct cdrom_multisession ms;
struct cdrom_subchnl sub;
static struct cdrom_multisession ms;
static struct cdrom_subchnl sub;
#endif
/* Used by `main' to communicate with `parse_opt'. And global options
*/
struct opts_s
static struct opts_s
{
int no_tracks;
int no_ioctl;
@@ -118,8 +118,6 @@ enum {
};
char *temp_str;
/* Parse source options. */
static void
parse_source(int opt)
@@ -175,7 +173,7 @@ parse_options (int argc, char *argv[])
{
int opt; /* used for argument parsing */
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" -a, --access-mode=STRING Set CD access method\n"
" -d, --debug=INT Set debugging to LEVEL\n"
@@ -243,7 +241,7 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-a|--access-mode STRING] [-d|--debug INT] [-T|--no-tracks]\n"
" [-A|--no-analyze] [--no-cddb] [-P|--cddb-port INT] [-H|--cddb-http]\n"
" [--cddb-server=STRING] [--cddb-cache=STRING] [--cddb-email=STRING]\n"
@@ -255,8 +253,8 @@ parse_options (int argc, char *argv[])
" [--no-joliet] [--no-rock-ridge] [--no-xa] [-q|--quiet] [-V|--version]\n"
" [-?|--help] [--usage]\n";
const char* optionsString = "a:d:TAP:HvIb::c::N::t::i::C::lqV?";
struct option optionsTable[] = {
static const char optionsString[] = "a:d:TAP:HvIb::c::N::t::i::C::lqV?";
static const struct option optionsTable[] = {
{"access-mode", required_argument, NULL, 'a'},
{"debug", required_argument, NULL, 'd' },
{"no-tracks", no_argument, NULL, 'T' },

View File

@@ -1,5 +1,5 @@
/*
$Id: buffering_write.c,v 1.3 2008/04/11 15:44:00 karl Exp $
$Id: buffering_write.c,v 1.4 2008/06/19 15:44:28 flameeyes Exp $
Copyright (C) 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1998, 1999 Monty <xiphmont@mit.edu>
@@ -39,7 +39,7 @@ static char bw_outbuf[OUTBUFSZ];
long int
static long int
blocking_write(int outf, char *buffer, long num){
long int words=0,temp;

View File

@@ -1,5 +1,5 @@
/*
$Id: buffering_write.h,v 1.3 2008/04/11 15:44:00 karl Exp $
$Id: buffering_write.h,v 1.4 2008/06/19 15:44:30 flameeyes Exp $
Copyright (C) 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1998 Monty <xiphmont@mit.edu>
@@ -18,8 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern long blocking_write(int outf, char *buffer, long i_num);
/** buffering_write() - buffers data to a specified size before writing.
*
* Restrictions:

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-paranoia.c,v 1.36 2008/04/11 15:44:00 karl Exp $
$Id: cd-paranoia.c,v 1.37 2008/06/19 15:44:30 flameeyes Exp $
Copyright (C) 2004, 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
(C) 1998 Monty <xiphmont@mit.edu>
@@ -282,13 +282,13 @@ static void usage(FILE *f)
fprintf( f, usage_help);
}
long callbegin;
long callend;
long callscript=0;
static long callbegin;
static long callend;
static long callscript=0;
static int skipped_flag=0;
static int abort_on_skip=0;
FILE *logfile = NULL;
static FILE *logfile = NULL;
#if TRACE_PARANOIA
static void
@@ -545,9 +545,9 @@ callback(long int inpos, paranoia_cb_mode_t function)
}
#endif /* !TRACE_PARANOIA */
const char *optstring = "aBcCd:efg:hi:l:m:n:o:O:pqQrRsS:Tt:VvwWx:XYZz::";
static const char optstring[] = "aBcCd:efg:hi:l:m:n:o:O:pqQrRsS:Tt:VvwWx:XYZz::";
struct option options [] = {
static const struct option options [] = {
{"abort-on-skip", no_argument, NULL, 'X'},
{"batch", no_argument, NULL, 'B'},
{"disable-extra-paranoia", no_argument, NULL, 'Y'},

View File

@@ -1,5 +1,5 @@
#!/usr/bin/perl
# $Id: pod2c.pl,v 1.3 2008/04/14 17:30:27 karl Exp $
# $Id: pod2c.pl,v 1.4 2008/06/19 15:44:31 flameeyes Exp $
# Utility to turn pieces of pod text to help text.
use File::Basename;
@@ -31,7 +31,7 @@ print "/*
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const char ${name}_help[] =\n";
static const char ${name}_help[] =\n";
while(<STDIN>) {
s/["]/\\"/g;
# Change POD'ed items to quoted items, e.g. See L<y> and L<z> becomes

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-read.c,v 1.32 2008/04/14 17:30:26 karl Exp $
$Id: cd-read.c,v 1.33 2008/06/19 15:44:13 flameeyes Exp $
Copyright (C) 2003, 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -76,7 +76,7 @@ typedef struct
/* Sub-options for --mode. Note: entries must be sorted! */
subopt_entry_t modes_sublist[] = {
static const subopt_entry_t modes_sublist[] = {
{"any", READ_ANY},
{"audio", READ_AUDIO},
{"m1f1", READ_M1F1},
@@ -92,7 +92,7 @@ subopt_entry_t modes_sublist[] = {
/* Used by `main' to communicate with `parse_opt'. And global options
*/
struct arguments
static struct arguments
{
char *access_mode; /* Access method driver should use for control */
char *output_file; /* file to output blocks if not NULL. */
@@ -155,7 +155,7 @@ compare_subopts(const void *key1, const void *key2)
flag variable to true as well as the "show.all" false.
*/
static void
process_suboption(const char *subopt, subopt_entry_t *sublist, const int num,
process_suboption(const char *subopt, const subopt_entry_t *sublist, const int num,
const char *subopt_name)
{
subopt_entry_t *subopt_rec =
@@ -238,7 +238,7 @@ parse_options (int argc, char *argv[])
{
int opt;
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" -a, --access-mode=STRING Set CD control access mode\n"
" -m, --mode=MODE-TYPE set CD-ROM read mode (audio, auto, m1f1, m1f2,\n"
@@ -271,7 +271,7 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-a|--access-mode STRING] [-m|--mode MODE-TYPE]\n"
" [-d|--debug INT] [-x|--hexdump] [--no-header] [--no-hexdump]\n"
" [-s|--start INT] [-e|--end INT] [-n|--number INT] [-b|--bin-file FILE]\n"
@@ -280,8 +280,8 @@ parse_options (int argc, char *argv[])
" [-V|--version] [-?|--help] [--usage]\n";
/* Command-line options */
const char* optionsString = "a:m:d:xjs:e:n:b::c::i::C::N::t::o:V?";
struct option optionsTable[] = {
static const char optionsString[] = "a:m:d:xjs:e:n:b::c::i::C::N::t::o:V?";
static const struct option optionsTable[] = {
{"access-mode", required_argument, NULL, 'a'},
{"mode", required_argument, NULL, 'm'},

View File

@@ -1,5 +1,5 @@
/*
$Id: cdda-player.c,v 1.49 2008/04/14 17:30:26 karl Exp $
$Id: cdda-player.c,v 1.50 2008/06/19 15:44:14 flameeyes Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -80,46 +80,46 @@ static void get_cdtext_track_info(track_t i_track);
static void get_track_info(track_t i_track);
static bool play_track(track_t t1, track_t t2);
CdIo_t *p_cdio; /* libcdio handle */
driver_id_t driver_id = DRIVER_DEVICE;
int b_sig = false; /* set on some signals */
static CdIo_t *p_cdio; /* libcdio handle */
static driver_id_t driver_id = DRIVER_DEVICE;
static int b_sig = false; /* set on some signals */
/* cdrom data */
track_t i_first_track;
track_t i_last_track;
track_t i_first_audio_track;
track_t i_last_audio_track;
track_t i_last_display_track = CDIO_INVALID_TRACK;
track_t i_tracks;
msf_t toc[CDIO_CDROM_LEADOUT_TRACK+1];
cdio_subchannel_t sub; /* subchannel last time read */
int i_data; /* # of data tracks present ? */
int start_track = 0;
int stop_track = 0;
int one_track = 0;
int i_vol_port = 5; /* If 5, retrieve volume port.
static track_t i_first_track;
static track_t i_last_track;
static track_t i_first_audio_track;
static track_t i_last_audio_track;
static track_t i_last_display_track = CDIO_INVALID_TRACK;
static track_t i_tracks;
static msf_t toc[CDIO_CDROM_LEADOUT_TRACK+1];
static cdio_subchannel_t sub; /* subchannel last time read */
static int i_data; /* # of data tracks present ? */
static int start_track = 0;
static int stop_track = 0;
static int one_track = 0;
static int i_vol_port = 5; /* If 5, retrieve volume port.
Otherwise the port number 0..3
of a working volume port and
4 for no working port.
*/
/* settings which can be set from the command or interactively. */
bool b_cd = false;
bool auto_mode = false;
bool b_verbose = false;
bool debug = false;
bool b_interactive = true;
bool b_prefer_cdtext = true;
bool b_cddb = false; /* CDDB database present */
bool b_db = false; /* we have a database at all */
bool b_record = false; /* we have a record for
the inserted CD */
bool b_all_tracks = false; /* True if we display all tracks*/
int8_t i_volume_level = -1; /* Valid range is 0..100 */
static bool b_cd = false;
static bool auto_mode = false;
static bool b_verbose = false;
static bool debug = false;
static bool b_interactive = true;
static bool b_prefer_cdtext = true;
static bool b_cddb = false; /* CDDB database present */
static bool b_db = false; /* we have a database at all */
static bool b_record = false; /* we have a record for
static the inserted CD */
static bool b_all_tracks = false; /* True if we display all tracks*/
static int8_t i_volume_level = -1; /* Valid range is 0..100 */
char *psz_device=NULL;
char *psz_program;
static char *psz_device=NULL;
static char *psz_program;
/* Info about songs and titles. The 0 entry will contain the disc info.
*/
@@ -132,30 +132,30 @@ typedef struct
bool b_cdtext; /* true if from CD-Text, false if from CDDB */
} cd_track_info_rec_t;
cd_track_info_rec_t cd_info[CDIO_CD_MAX_TRACKS+2];
static cd_track_info_rec_t cd_info[CDIO_CD_MAX_TRACKS+2];
char title[80];
char artist[80];
char genre[40];
char category[40];
char year[5];
static char title[80];
static char artist[80];
static char genre[40];
static char category[40];
static char year[5];
bool b_cdtext_title; /* true if from CD-Text, false if from CDDB */
bool b_cdtext_artist; /* true if from CD-Text, false if from CDDB */
bool b_cdtext_genre; /* true if from CD-Text, false if from CDDB */
bool b_cdtext_category; /* true if from CD-Text, false if from CDDB */
bool b_cdtext_year; /* true if from CD-Text, false if from CDDB */
static bool b_cdtext_title; /* true if from CD-Text, false if from CDDB */
static bool b_cdtext_artist; /* true if from CD-Text, false if from CDDB */
static bool b_cdtext_genre; /* true if from CD-Text, false if from CDDB */
static bool b_cdtext_category; /* true if from CD-Text, false if from CDDB */
static bool b_cdtext_year; /* true if from CD-Text, false if from CDDB */
cdio_audio_volume_t audio_volume;
static cdio_audio_volume_t audio_volume;
#ifdef HAVE_CDDB
cddb_conn_t *p_conn = NULL;
cddb_disc_t *p_cddb_disc = NULL;
int i_cddb_matches = 0;
static cddb_conn_t *p_conn = NULL;
static cddb_disc_t *p_cddb_disc = NULL;
static int i_cddb_matches = 0;
#endif
#define MAX_KEY_STR 50
const char key_bindings[][MAX_KEY_STR] = {
static const char key_bindings[][MAX_KEY_STR] = {
" right play / next track",
" left previous track",
" up/down 10 sec forward / back",
@@ -176,7 +176,7 @@ const char key_bindings[][MAX_KEY_STR] = {
" + increase volume level",
};
const unsigned int i_key_bindings = sizeof(key_bindings) / MAX_KEY_STR;
static const unsigned int i_key_bindings = sizeof(key_bindings) / MAX_KEY_STR;
/* ---------------------------------------------------------------------- */
/* tty stuff */
@@ -197,9 +197,9 @@ typedef enum {
} track_line_t;
unsigned int LINE_ACTION = 25;
unsigned int COLS_LAST;
char psz_action_line[300] = "";
static unsigned int LINE_ACTION = 25;
static unsigned int COLS_LAST;
static char psz_action_line[300] = "";
static int rounded_div(unsigned int i_a, unsigned int i_b)
{

View File

@@ -1,5 +1,5 @@
/*
$Id: iso-info.c,v 1.39 2008/04/14 17:30:27 karl Exp $
$Id: iso-info.c,v 1.40 2008/06/19 15:44:16 flameeyes Exp $
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -58,7 +58,7 @@
/* Used by `main' to communicate with `parse_opt'. And global options
*/
struct arguments
static struct arguments
{
uint32_t debug_level;
int version_only;
@@ -82,16 +82,13 @@ enum {
};
char *temp_str;
/* Parse a all options. */
static bool
parse_options (int argc, char *argv[])
{
int opt;
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" -d, --debug=INT Set debugging to LEVEL\n"
" -i, --input[=FILE] Filename to read ISO-9960 image from\n"
@@ -111,13 +108,13 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-d|--debug INT] [-i|--input FILE] [-f] [-l|--iso9660]\n"
" [--no-header] [--no-joliet] [--no-rock-ridge] [--no-xa] [-q|--quiet]\n"
" [-V|--version] [-?|--help] [--usage]\n";
const char* optionsString = "d:i::flqV?";
struct option optionsTable[] = {
static const char optionsString[] = "d:i::flqV?";
static const struct option optionsTable[] = {
{"debug", required_argument, NULL, 'd'},
{"input", optional_argument, NULL, 'i'},
{"iso9660", no_argument, NULL, 'l'},

View File

@@ -1,5 +1,5 @@
/*
$Id: iso-read.c,v 1.15 2008/04/14 17:30:27 karl Exp $
$Id: iso-read.c,v 1.16 2008/06/19 15:44:19 flameeyes Exp $
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -48,7 +48,7 @@
/* Used by `main' to communicate with `parse_opt'. And global options
*/
struct arguments
static struct arguments
{
char *file_name;
char *output_file;
@@ -72,7 +72,7 @@ parse_options (int argc, char *argv[])
OP_USAGE
};
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" -d, --debug=INT Set debugging to LEVEL.\n"
" -i, --image=FILE Read from ISO-9660 image. This option is mandatory\n"
@@ -88,14 +88,14 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-d|--debug INT] [-i|--image FILE] [-e|--extract FILE]\n"
" [--no-header] [-o|--output-file FILE] [-V|--version] [-?|--help]\n"
" [--usage]\n";
/* Command-line options */
const char* optionsString = "d:i:e:o:Vk?";
struct option optionsTable[] = {
static const char* optionsString = "d:i:e:o:Vk?";
static const struct option optionsTable[] = {
{"debug", required_argument, NULL, 'd' },
{"image", required_argument, NULL, 'i' },
{"extract", required_argument, NULL, 'e' },

View File

@@ -1,5 +1,5 @@
/*
$Id: mmc-tool.c,v 1.11 2008/04/14 17:30:27 karl Exp $
$Id: mmc-tool.c,v 1.12 2008/06/19 15:44:24 flameeyes Exp $
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
@@ -78,8 +78,8 @@ typedef struct
enum { MAX_OPS = 10 };
unsigned int last_op = 0;
operation_t operation[MAX_OPS] = { {OP_FINISHED, {0}} };
static unsigned int last_op = 0;
static operation_t operation[MAX_OPS] = { {OP_FINISHED, {0}} };
static void
push_op(operation_t *p_op)
@@ -98,7 +98,7 @@ parse_options (int argc, char *argv[])
operation_t op;
int i_blocksize = 0;
const char* helpText =
static const char helpText[] =
"Usage: %s [OPTION...]\n"
" Issues libcdio Multimedia commands. Operations occur in the order\n"
" in which the options are given and a given operation may appear\n"
@@ -127,14 +127,14 @@ parse_options (int argc, char *argv[])
" -?, --help Show this help message\n"
" --usage Display brief usage message\n";
const char* usageText =
static const char usageText[] =
"Usage: %s [-b|--blocksize[=INT]] [-m|--mcn]\n"
" [-I|--idle] [-I|inquiry] [-m[-s|--speed-KB INT]\n"
" [-V|--version] [-?|--help] [--usage]\n";
/* Command-line options */
const char* optionsString = "b::c:C::e::Iis:V?";
struct option optionsTable[] = {
static const char optionsString[] = "b::c:C::e::Iis:V?";
const struct option optionsTable[] = {
{"blocksize", optional_argument, &i_blocksize, 'b' },
{"close", required_argument, NULL, 'c'},