Ticket #1649: Prepare for prerelease mc-4.7.0-pre3 (code cleanup)

Try to compile with
{{{
make CFLAGS="-Wall -Werror -Wno-long-long -Wwrite-strings"
}}}

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2009-09-30 02:09:54 +03:00
parent 4c64340111
commit dd94068a62
20 changed files with 48 additions and 181 deletions

View File

@ -485,7 +485,7 @@ edit_get_save_file_as (WEdit *edit)
char *filename = edit->filename;
char *lb_names[LB_NAMES] =
const char *lb_names[LB_NAMES] =
{
N_("&Do not change"),
N_("&Unix format (LF)"),
@ -497,7 +497,7 @@ edit_get_save_file_as (WEdit *edit)
{
QUICK_BUTTON (6, 10, DLG_HEIGHT - 3, DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (2, 10, DLG_HEIGHT - 3, DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
QUICK_RADIO (5, DLG_WIDTH, DLG_HEIGHT - 8, DLG_HEIGHT, LB_NAMES, (const char **) lb_names, &cur_lb),
QUICK_RADIO (5, DLG_WIDTH, DLG_HEIGHT - 8, DLG_HEIGHT, LB_NAMES, lb_names, (int *) &cur_lb),
QUICK_LABEL (3, DLG_WIDTH, DLG_HEIGHT - 9, DLG_HEIGHT, N_("Change line breaks to:")),
QUICK_INPUT (3, DLG_WIDTH, DLG_HEIGHT - 11, DLG_HEIGHT, filename, DLG_WIDTH - 6, 0, "save-as", &filename),
QUICK_LABEL (2, DLG_WIDTH, DLG_HEIGHT - 12, DLG_HEIGHT, N_(" Enter file name: ")),
@ -2315,9 +2315,10 @@ static gboolean is_break_char(char c)
}
/* find first character of current word */
static int edit_find_word_start (WEdit *edit, long *word_start, int *word_len)
static int edit_find_word_start (WEdit *edit, long *word_start, gsize *word_len)
{
int i, c, last;
int c, last;
gsize i;
/* return if at begin of file */
if (edit->curs1 <= 0)
@ -2354,10 +2355,10 @@ static int edit_find_word_start (WEdit *edit, long *word_start, int *word_len)
#define MAX_WORD_COMPLETIONS 100 /* in listbox */
/* collect the possible completions */
static int
edit_collect_completions (WEdit *edit, long start, int word_len,
static gsize
edit_collect_completions (WEdit *edit, long start, gsize word_len,
char *match_expr, struct selection *compl,
int *num)
gsize *num)
{
gsize len = 0;
gsize max_len = 0;
@ -2461,8 +2462,7 @@ edit_collect_completions (WEdit *edit, long start, int word_len,
void
edit_complete_word_cmd (WEdit *edit)
{
int word_len = 0, num_compl = 0;
gsize i, max_len;
gsize i, max_len, word_len = 0, num_compl = 0;
long word_start = 0;
unsigned char *bufpos;
char *match_expr;
@ -2507,7 +2507,7 @@ edit_complete_word_cmd (WEdit *edit)
g_free (match_expr);
/* release memory before return */
for (i = 0; i < (gsize) num_compl; i++)
for (i = 0; i < num_compl; i++)
g_free (compl[i].text);
}
@ -2638,9 +2638,8 @@ edit_load_back_cmd (WEdit *edit)
void
edit_get_match_keyword_cmd (WEdit *edit)
{
int word_len = 0;
gsize word_len = 0, max_len = 0;
int num_def = 0;
int max_len = 0;
int i;
long word_start = 0;
unsigned char *bufpos;

View File

@ -105,7 +105,7 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha
/* 5 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards),
/* 6 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
/* 7 */ QUICK_RADIO (3, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT,
num_of_types, (const char **) list_of_types, &edit->search_type),
num_of_types, (const char **) list_of_types, (int *) &edit->search_type),
/* 8 */ QUICK_LABEL (2, REPLACE_DLG_WIDTH, 4, REPLACE_DLG_HEIGHT, N_(" Enter replacement string:")),
/* 9 */ QUICK_INPUT (3, REPLACE_DLG_WIDTH, 5, REPLACE_DLG_HEIGHT,
replace_default, REPLACE_DLG_WIDTH - 6, 0, "replace", replace_text),
@ -144,7 +144,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text)
size_t num_of_types;
gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types);
int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + num_of_types - SEARCH_DLG_HEIGHT_SUPPLY;
int i;
size_t i;
int dialog_result;
@ -170,7 +170,7 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text)
QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
/* 8 */
QUICK_RADIO ( 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
num_of_types, (const char **) list_of_types, &edit->search_type),
num_of_types, (const char **) list_of_types, (int *) &edit->search_type),
/* 9 */
QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
*search_text, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text),
@ -180,9 +180,9 @@ editcmd_dialog_search_show (WEdit * edit, char **search_text)
};
#ifdef HAVE_CHARSET
int last_checkbox = 7;
size_t last_checkbox = 7;
#else
int last_checkbox = 6;
size_t last_checkbox = 6;
#endif
QuickDialog Quick_input =

View File

@ -387,7 +387,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
q)) + edit->start_col;
if ( option_line_state ) {
cur_line = edit->start_line + row;
if ( cur_line <= edit->total_lines ) {
if ( cur_line <= (unsigned int) edit->total_lines ) {
g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
} else {
memset(line_stat, ' ', LINE_STATE_WIDTH);

View File

@ -346,7 +346,7 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first)
/* dialog */
quick_dlg.xlen = dlg_width;
/* widgets */
for (i = 0; i < sizeof (quick_widgets)/sizeof (quick_widgets[0]) - 1; i++)
for (i = 0; (size_t) i < sizeof (quick_widgets)/sizeof (quick_widgets[0]) - 1; i++)
quick_widgets[i].x_divisions = dlg_width;
/* buttons */
quick_widgets[0].relative_x = dlg_width * 2/3 - cancel_len/2;

View File

@ -819,9 +819,9 @@ char *
file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
const char *def_text, int only_one, int *do_background)
{
const int FMDY = 13;
const int FMDX = 64;
int fmd_xlen = 0;
const size_t FMDY = 13;
const size_t FMDX = 64;
size_t fmd_xlen = 0;
int source_easy_patterns = easy_patterns;
size_t i, len;

View File

@ -128,6 +128,7 @@ static int
mc_fhl_get_color_filetype (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, file_entry * fe)
{
gboolean my_color = FALSE;
(void) fhl;
switch (mc_filter->file_type) {
case MC_FLHGH_FTYPE_T_FILE:
@ -202,6 +203,7 @@ mc_fhl_get_color_filetype (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, file_ent
static int
mc_fhl_get_color_regexp (mc_fhl_filter_t * mc_filter, mc_fhl_t * fhl, file_entry * fe)
{
(void) fhl;
if (mc_filter->search_condition == NULL)
return -1;

View File

@ -315,89 +315,6 @@ GArray *input_keymap = NULL;
const global_key_map_t *main_map;
const global_key_map_t *main_x_map;
static void
reload_panelized (WPanel *panel)
{
int i, j;
dir_list *list = &panel->dir;
if (panel != current_panel)
mc_chdir (panel->cwd);
for (i = 0, j = 0; i < panel->count; i++) {
if (list->list[i].f.marked) {
/* Unmark the file in advance. In case the following mc_lstat
* fails we are done, else we have to mark the file again
* (Note: do_file_mark depends on a valid "list->list [i].buf").
* IMO that's the best way to update the panel's summary status
* -- Norbert
*/
do_file_mark (panel, i, 0);
}
if (mc_lstat (list->list[i].fname, &list->list[i].st)) {
g_free (list->list[i].fname);
continue;
}
if (list->list[i].f.marked)
do_file_mark (panel, i, 1);
if (j != i)
list->list[j] = list->list[i];
j++;
}
if (j == 0)
panel->count = set_zero_dir (list);
else
panel->count = j;
if (panel != current_panel)
mc_chdir (current_panel->cwd);
}
static void
update_one_panel_widget (WPanel *panel, int force_update,
const char *current_file)
{
int free_pointer;
char *my_current_file = NULL;
if (force_update & UP_RELOAD) {
panel->is_panelized = 0;
mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0);
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
}
/* If current_file == -1 (an invalid pointer) then preserve selection */
if (current_file == UP_KEEPSEL) {
free_pointer = 1;
my_current_file = g_strdup (panel->dir.list[panel->selected].fname);
current_file = my_current_file;
} else
free_pointer = 0;
if (panel->is_panelized)
reload_panelized (panel);
else
panel_reload (panel);
try_to_select (panel, current_file);
panel->dirty = 1;
if (free_pointer)
g_free (my_current_file);
}
static void
update_one_panel (int which, int force_update, const char *current_file)
{
WPanel *panel;
if (get_display_type (which) != view_listing)
return;
panel = (WPanel *) get_panel_widget (which);
update_one_panel_widget (panel, force_update, current_file);
}
/* Save current stat of directories to avoid reloading the panels */
/* when no modifications have taken place */
void
@ -1197,11 +1114,6 @@ ctl_x_cmd (void)
ctl_x_map_enabled = 1;
}
static void
nothing (void)
{
}
static cb_ret_t
midnight_execute_cmd(int command)
{

View File

@ -123,62 +123,6 @@ mcview_continue_search_cmd (mcview_t * view)
}
}
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t
mcview_handle_editkey (mcview_t * view, int key)
{
struct hexedit_change_node *node;
int byte_val;
/* Has there been a change at this position? */
node = view->change_list;
while (node && (node->offset != view->hex_cursor))
node = node->next;
if (!view->hexview_in_text) {
/* Hex editing */
unsigned int hexvalue = 0;
if (key >= '0' && key <= '9')
hexvalue = 0 + (key - '0');
else if (key >= 'A' && key <= 'F')
hexvalue = 10 + (key - 'A');
else if (key >= 'a' && key <= 'f')
hexvalue = 10 + (key - 'a');
else
return MSG_NOT_HANDLED;
if (node)
byte_val = node->value;
else
mcview_get_byte (view, view->hex_cursor, &byte_val);
if (view->hexedit_lownibble) {
byte_val = (byte_val & 0xf0) | (hexvalue);
} else {
byte_val = (byte_val & 0x0f) | (hexvalue << 4);
}
} else {
/* Text editing */
if (key < 256 && ((key == '\n') || is_printable (key)))
byte_val = key;
else
return MSG_NOT_HANDLED;
}
if (!node) {
node = g_new (struct hexedit_change_node, 1);
node->offset = view->hex_cursor;
node->value = byte_val;
mcview_enqueue_change (&view->change_list, node);
} else {
node->value = byte_val;
}
view->dirty++;
mcview_update (view);
mcview_move_right (view, 1);
return MSG_HANDLED;
}
/* --------------------------------------------------------------------------------------------- */
/* Check for left and right arrows, possibly with modifiers */
@ -289,6 +233,7 @@ static cb_ret_t
mcview_execute_cmd (mcview_t * view, int command, int key)
{
int res = MSG_HANDLED;
(void) key;
if (view->hex_mode) {
switch (command) {

View File

@ -92,7 +92,7 @@ mcview_dialog_search (mcview_t * view)
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
N_("case &Sensitive"), &view->search_case),
QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
num_of_types, (const char **) list_of_types, &view->search_type),
num_of_types, (const char **) list_of_types, (int *) &view->search_type),
QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, &exp),
QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),

View File

@ -170,7 +170,6 @@ mcview_real_event (Gpm_Event * event, void *x)
static void
mcview_set_keymap (mcview_t * view)
{
int i;
view->plain_map = default_viewer_keymap;
if (viewer_keymap && viewer_keymap->len > 0)
view->plain_map = (global_key_map_t *) viewer_keymap->data;

View File

@ -68,7 +68,7 @@ mcview_display_text (mcview_t * view)
screen_dimen row, col;
off_t from;
int cw = 1;
unsigned int c, prev_ch;
int c, prev_ch;
gboolean read_res = TRUE;
struct hexedit_change_node *curr = view->change_list;

View File

@ -405,7 +405,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
for (i = 0; i < qw->u.radio.count; i++)
items[i] = g_strdup (qw->u.radio.items[i]);
r = radio_new (ypos, xpos, qw->u.radio.count, items);
r = radio_new (ypos, xpos, qw->u.radio.count, (const char **) items);
r->pos = r->sel = *qw->u.radio.value;
qw->widget = (Widget *) r;
g_strfreev (items);

View File

@ -118,6 +118,7 @@ static size_t format_pos = 0;
*/
void setup_logging( const char *pname, BOOL interactive )
{
(void) pname;
if( interactive )
{
stdout_logging = True;

View File

@ -1145,6 +1145,7 @@ void interpret_coding_system(const char *str)
static size_t skip_non_multibyte_char(char c)
{
(void) c;
return 0;
}
@ -1154,6 +1155,7 @@ static size_t skip_non_multibyte_char(char c)
static BOOL not_multibyte_char_1(char c)
{
(void) c;
return False;
}

View File

@ -334,7 +334,7 @@ check if it's a null mtime
****************************************************************************/
BOOL null_mtime(time_t mtime)
{
if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
if (mtime == (time_t)0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
return(True);
return(False);
}

View File

@ -1994,6 +1994,7 @@ static char *automount_lookup(char *user_name)
static char *automount_server(const char *user_name)
{
static pstring server_name;
(void) user_name;
/* use the local machine name as the default */
/* this will be the default if WITH_AUTOMOUNT is not used or fails */
@ -2123,7 +2124,7 @@ void standard_sub_basic(char *str)
}
r = p+3;
copylen = MIN((q-r),(sizeof(envname)-1));
copylen = MIN((size_t)(q-r),(size_t)(sizeof(envname)-1));
strncpy(envname,r,copylen);
envname[copylen] = '\0';
@ -2135,7 +2136,7 @@ void standard_sub_basic(char *str)
break;
}
copylen = MIN((q+1-p),(sizeof(envname)-1));
copylen = MIN((size_t)(q+1-p),(size_t)(sizeof(envname)-1));
strncpy(envname,p,copylen);
envname[copylen] = '\0';
string_sub(p,envname,envval);

View File

@ -708,7 +708,7 @@ BOOL cli_session_setup(struct cli_state *cli,
if (cli->protocol < PROTOCOL_LANMAN1)
return True;
if (passlen > sizeof(pword)-1 || ntpasslen > sizeof(ntpword)-1) {
if ((size_t) passlen > sizeof(pword)-1 || (size_t)ntpasslen > sizeof(ntpword)-1) {
return False;
}
@ -1356,7 +1356,7 @@ size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t
int size2;
while (issued - received < mpx && issued < blocks) {
int size1 = MIN(block, size-issued*block);
int size1 = MIN(block, (int) size-issued*block);
cli_issue_read(cli, fnum, offset+issued*block, size1, issued);
issued++;
}
@ -1466,7 +1466,7 @@ ssize_t cli_write(struct cli_state *cli,
while ((issued - received < mpx) && (issued < blocks))
{
int bsent = issued * block;
int size1 = MIN(block, size - bsent);
int size1 = MIN(block, (int) size - bsent);
cli_issue_write(cli, fnum, offset + bsent,
write_mode,

View File

@ -509,7 +509,7 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
}
pstrcpy(name_resolve_list, lp_name_resolve_order());
if (!name_resolve_list || !*name_resolve_list)
if (name_resolve_list == NULL || *name_resolve_list == '\0')
pstrcpy(name_resolve_list, "host");
ptr = name_resolve_list;

View File

@ -203,7 +203,7 @@ static int parse_nmb_name(char *inbuf,int offset,int length, struct nmb_name *na
unsigned char c1,c2;
c1 = ubuf[offset++]-'A';
c2 = ubuf[offset++]-'A';
if ((c1 & 0xF0) || (c2 & 0xF0) || (n > sizeof(name->name)-1))
if ((c1 & 0xF0) || (c2 & 0xF0) || ((size_t) n > sizeof(name->name)-1))
return(0);
name->name[n++] = (c1<<4) | c2;
m -= 2;
@ -234,7 +234,7 @@ static int parse_nmb_name(char *inbuf,int offset,int length, struct nmb_name *na
ret += m+1;
if (n)
name->scope[n++] = '.';
if (m+2+offset>length || n+m+1>sizeof(name->scope))
if (m+2+offset>length || (size_t) n+m+1 >sizeof(name->scope))
return(0);
offset++;
while (m--)
@ -340,7 +340,7 @@ static BOOL parse_alloc_res_rec(char *inbuf,int *offset,int length,
(*recs)[i].ttl = RIVAL(inbuf,(*offset)+4);
(*recs)[i].rdlength = RSVAL(inbuf,(*offset)+8);
(*offset) += 10;
if ((*recs)[i].rdlength>sizeof((*recs)[i].rdata) ||
if ((size_t)(*recs)[i].rdlength>sizeof((*recs)[i].rdata) ||
(*offset)+(*recs)[i].rdlength > length) {
free(*recs);
return(False);
@ -431,7 +431,7 @@ static BOOL parse_dgram(char *inbuf,int length,struct dgram_packet *dgram)
offset += parse_nmb_name(inbuf,offset,length,&dgram->dest_name);
}
if (offset >= length || (length-offset > sizeof(dgram->data)))
if (offset >= length || ((size_t)length-offset > sizeof(dgram->data)))
return(False);
dgram->datasize = length-offset;
@ -630,6 +630,7 @@ static void free_nmb_packet(struct nmb_packet *nmb)
static void free_dgram_packet(struct dgram_packet *nmb)
{
/* We have nothing to do for a dgram packet. */
(void) nmb;
}
/*******************************************************************

View File

@ -45,6 +45,7 @@ de-obfuscates a password
****************************************************************************/
static void pwd_deobfuscate(struct pwd_info *pwd)
{
(void) pwd;
}
/****************************************************************************
@ -52,6 +53,7 @@ obfuscates a password
****************************************************************************/
static void pwd_obfuscate(struct pwd_info *pwd)
{
(void) pwd;
}
/****************************************************************************
@ -59,6 +61,9 @@ sets the obfuscation key info
****************************************************************************/
void pwd_obfuscate_key(struct pwd_info *pwd, uint32 int_key, char *str_key)
{
(void) pwd;
(void) int_key;
(void) str_key;
}
#if 0