mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-11 02:21:45 +03:00
Merge branch '2356_view_segfault_arm'
* 2356_view_segfault_arm: lib/vfs/mc-vfs/smbfs.c: fixed printf() arguments. Fixed type mismatches in formatted output arguments in VFS. Fixed signed and unsigned comparisons in viewer. Ticket 2356: viewer segfaults on ARM platform because type mismatches of printf arguments.
This commit is contained in:
commit
e269adf31c
@ -35,6 +35,7 @@
|
||||
/* includes fcntl.h see IEEE Std 1003.1-2008 */
|
||||
#include <time.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
@ -980,9 +981,9 @@ vfs_s_print_stats (const char *fs_name, const char *action,
|
||||
|
||||
if (need)
|
||||
print_vfs_message (i18n_percent_transf_format, fs_name, action,
|
||||
file_name, (int) ((double) have * 100 / need), have);
|
||||
file_name, (int) ((double) have * 100 / need), (uintmax_t) have);
|
||||
else
|
||||
print_vfs_message (i18n_transf_format, fs_name, action, file_name, have);
|
||||
print_vfs_message (i18n_transf_format, fs_name, action, file_name, (uintmax_t) have);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/fs.h"
|
||||
@ -803,14 +804,14 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
|
||||
{
|
||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%ju;\n",
|
||||
SUP.scr_append, (char *) NULL);
|
||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name, s.st_size);
|
||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name, (uintmax_t) s.st_size);
|
||||
g_free (shell_commands);
|
||||
}
|
||||
else
|
||||
{
|
||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_FILESIZE=%ju;\n",
|
||||
SUP.scr_send, (char *) NULL);
|
||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name, s.st_size);
|
||||
n = fish_command (me, super, WAIT_REPLY, shell_commands, quoted_name, (uintmax_t) s.st_size);
|
||||
g_free (shell_commands);
|
||||
}
|
||||
if (n != PRELIM)
|
||||
@ -848,7 +849,7 @@ fish_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *lo
|
||||
tty_disable_interrupt_key ();
|
||||
total += n;
|
||||
print_vfs_message (_("fish: storing %s %d (%ju)"),
|
||||
was_error ? _("zeros") : _("file"), total, s.st_size);
|
||||
was_error ? _("zeros") : _("file"), total, (uintmax_t) s.st_size);
|
||||
}
|
||||
close (h);
|
||||
g_free (quoted_name);
|
||||
@ -886,7 +887,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
|
||||
|
||||
shell_commands = g_strconcat (SUP.scr_env, "FISH_FILENAME=%s FISH_START_OFFSET=%ju;\n",
|
||||
SUP.scr_get, (char *) NULL);
|
||||
offset = fish_command (me, super, WANT_STRING, shell_commands, quoted_name, offset);
|
||||
offset = fish_command (me, super, WANT_STRING, shell_commands, quoted_name, (uintmax_t) offset);
|
||||
g_free (shell_commands);
|
||||
g_free (quoted_name);
|
||||
if (offset != PRELIM)
|
||||
|
@ -84,6 +84,7 @@ What to do with this?
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
@ -1738,7 +1739,8 @@ ftpfs_file_store (struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *l
|
||||
w_buf += n_written;
|
||||
n_read -= n_written;
|
||||
}
|
||||
print_vfs_message (_("ftpfs: storing file %ju (%ju)"), n_stored, s.st_size);
|
||||
print_vfs_message (_("ftpfs: storing file %ju (%ju)"),
|
||||
(uintmax_t) n_stored, (uintmax_t) s.st_size);
|
||||
}
|
||||
tty_disable_interrupt_key ();
|
||||
close (sock);
|
||||
|
@ -1667,7 +1667,7 @@ smbfs_mknod (struct vfs_class *me, const char *path, mode_t mode, dev_t dev)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
DEBUG(3, ("smbfs_mknod(path:%s, mode:%d, dev:%zu)\n", path, mode, dev));
|
||||
DEBUG(3, ("smbfs_mknod(path:%s, mode:%d, dev:%u)\n", path, mode, (unsigned int)dev));
|
||||
my_errno = EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
@ -52,6 +52,9 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h> /* for g_memmove() */
|
||||
#ifdef MC_ENABLE_DEBUGGING_CODE
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
#endif
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
@ -217,16 +220,15 @@ mcview_ccache_dump (mcview_t * view)
|
||||
(void) setvbuf (f, NULL, _IONBF, 0);
|
||||
|
||||
/* cache entries */
|
||||
for (i = 0; i < view->coord_cache->size; i++)
|
||||
for (i = 0; i < cache->size; i++)
|
||||
{
|
||||
(void) fprintf (f,
|
||||
"entry %8u "
|
||||
"offset %8" OFFSETTYPE_PRId " "
|
||||
"line %8" OFFSETTYPE_PRId " "
|
||||
"column %8" OFFSETTYPE_PRId " "
|
||||
"nroff_column %8" OFFSETTYPE_PRId "\n",
|
||||
(unsigned int) i, cache->cache[i].cc_offset, cache[i]->cache.cc_line,
|
||||
cache->cache[i].cc_column, cache->cache[i].cc_nroff_column);
|
||||
"entry %8u offset %8ju line %8ju column %8ju nroff_column %8ju\n",
|
||||
(unsigned int) i,
|
||||
(uintmax_t) cache->cache[i]->cc_offset,
|
||||
(uintmax_t) cache->cache[i]->cc_line,
|
||||
(uintmax_t) cache->cache[i]->cc_column,
|
||||
(uintmax_t) cache->cache[i]->cc_nroff_column);
|
||||
}
|
||||
(void) fprintf (f, "\n");
|
||||
|
||||
@ -235,16 +237,15 @@ mcview_ccache_dump (mcview_t * view)
|
||||
{
|
||||
mcview_offset_to_coord (view, &line, &column, offset);
|
||||
(void) fprintf (f,
|
||||
"offset %8" OFFSETTYPE_PRId " "
|
||||
"line %8" OFFSETTYPE_PRId " "
|
||||
"column %8" OFFSETTYPE_PRId "\n", offset, line, column);
|
||||
"offset %8ju line %8ju column %8ju\n",
|
||||
(uintmax_t) offset, (uintmax_t) line, (uintmax_t) column);
|
||||
}
|
||||
|
||||
/* line/column -> offset translation */
|
||||
for (line = 0; TRUE; line++)
|
||||
{
|
||||
mcview_coord_to_offset (view, &nextline_offset, line + 1, 0);
|
||||
(void) fprintf (f, "nextline_offset %8" OFFSETTYPE_PRId "\n", nextline_offset);
|
||||
(void) fprintf (f, "nextline_offset %8ju\n", (uintmax_t) nextline_offset);
|
||||
|
||||
for (column = 0; TRUE; column++)
|
||||
{
|
||||
@ -253,8 +254,8 @@ mcview_ccache_dump (mcview_t * view)
|
||||
break;
|
||||
|
||||
(void) fprintf (f,
|
||||
"line %8" OFFSETTYPE_PRId " column %8" OFFSETTYPE_PRId " offset %8"
|
||||
OFFSETTYPE_PRId "\n", line, column, offset);
|
||||
"line %8ju column %8ju offset %8ju\n",
|
||||
(uintmax_t) line, (uintmax_t) column, (uintmax_t) offset);
|
||||
}
|
||||
|
||||
if (nextline_offset >= filesize - 1)
|
||||
|
@ -36,6 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/skin.h"
|
||||
@ -148,13 +149,11 @@ mcview_display_status (mcview_t * view)
|
||||
char buffer[BUF_TINY];
|
||||
widget_move (view, top, width - 32);
|
||||
if (view->hex_mode)
|
||||
{
|
||||
tty_printf ("0x%08lx", (unsigned long) view->hex_cursor);
|
||||
}
|
||||
tty_printf ("0x%08jx", (uintmax_t) view->hex_cursor);
|
||||
else
|
||||
{
|
||||
size_trunc_len (buffer, 5, mcview_get_filesize (view), 0, panels_options.kilobyte_si);
|
||||
tty_printf ("%9lli/%s%s %s", view->dpy_end,
|
||||
tty_printf ("%9ju/%s%s %s", (uintmax_t) view->dpy_end,
|
||||
buffer, mcview_may_still_grow (view) ? "+" : " ",
|
||||
#ifdef HAVE_CHARSET
|
||||
source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
|
||||
@ -377,7 +376,7 @@ mcview_display_ruler (mcview_t * view)
|
||||
|
||||
if ((cl != 0) && (cl % 10) == 0)
|
||||
{
|
||||
g_snprintf (r_buff, sizeof (r_buff), "%" OFFSETTYPE_PRId, (long unsigned int) cl);
|
||||
g_snprintf (r_buff, sizeof (r_buff), "%ju", (uintmax_t) cl);
|
||||
if (nums_row < height)
|
||||
{
|
||||
widget_move (view, top + nums_row, left + c - 1);
|
||||
|
@ -177,7 +177,7 @@ mcview_get_byte_growing_buffer (mcview_t * view, off_t byte_index, int *retval)
|
||||
off_t pageno;
|
||||
off_t pageindex;
|
||||
|
||||
if (retval)
|
||||
if (retval != NULL)
|
||||
*retval = -1;
|
||||
|
||||
pageno = byte_index / VIEW_PAGE_SIZE;
|
||||
@ -191,15 +191,16 @@ mcview_get_byte_growing_buffer (mcview_t * view, off_t byte_index, int *retval)
|
||||
mcview_growbuf_read_until (view, byte_index + 1);
|
||||
if (view->growbuf_blockptr->len == 0)
|
||||
return FALSE;
|
||||
if (pageno < view->growbuf_blockptr->len - 1)
|
||||
if (pageno < (off_t) view->growbuf_blockptr->len - 1)
|
||||
{
|
||||
if (retval)
|
||||
if (retval != NULL)
|
||||
*retval = *((byte *) (g_ptr_array_index (view->growbuf_blockptr, pageno) + pageindex));
|
||||
return TRUE;
|
||||
}
|
||||
if (pageno == view->growbuf_blockptr->len - 1 && pageindex < (off_t) view->growbuf_lastindex)
|
||||
if (pageno == (off_t) view->growbuf_blockptr->len - 1
|
||||
&& pageindex < (off_t) view->growbuf_lastindex)
|
||||
{
|
||||
if (retval)
|
||||
if (retval != NULL)
|
||||
*retval = *((byte *) (g_ptr_array_index (view->growbuf_blockptr, pageno) + pageindex));
|
||||
return TRUE;
|
||||
}
|
||||
@ -222,9 +223,10 @@ mcview_get_ptr_growing_buffer (mcview_t * view, off_t byte_index)
|
||||
mcview_growbuf_read_until (view, byte_index + 1);
|
||||
if (view->growbuf_blockptr->len == 0)
|
||||
return NULL;
|
||||
if (pageno < view->growbuf_blockptr->len - 1)
|
||||
if (pageno < (off_t) view->growbuf_blockptr->len - 1)
|
||||
return (char *) (g_ptr_array_index (view->growbuf_blockptr, pageno) + pageindex);
|
||||
if (pageno == view->growbuf_blockptr->len - 1 && pageindex < (off_t) view->growbuf_lastindex)
|
||||
if (pageno == (off_t) view->growbuf_blockptr->len - 1
|
||||
&& pageindex < (off_t) view->growbuf_lastindex)
|
||||
return (char *) (g_ptr_array_index (view->growbuf_blockptr, pageno) + pageindex);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h> /* uintmax_t */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
@ -159,8 +160,7 @@ mcview_display_hex (mcview_t * view)
|
||||
col = 0;
|
||||
|
||||
/* Print the hex offset */
|
||||
g_snprintf (hex_buff, sizeof (hex_buff), "%08" OFFSETTYPE_PRIX " ",
|
||||
(long unsigned int) from);
|
||||
g_snprintf (hex_buff, sizeof (hex_buff), "%08jX ", (uintmax_t) from);
|
||||
widget_move (view, top + row, left);
|
||||
tty_setcolor (MARKED_COLOR);
|
||||
for (i = 0; col < width && hex_buff[i] != '\0'; i++)
|
||||
|
@ -21,9 +21,6 @@ typedef unsigned char byte;
|
||||
/* A width or height on the screen */
|
||||
typedef unsigned int screen_dimen;
|
||||
|
||||
#define OFFSETTYPE_PRIX "lX"
|
||||
#define OFFSETTYPE_PRId "lu"
|
||||
|
||||
extern const off_t INVALID_OFFSET;
|
||||
extern const off_t OFFSETTYPE_MAX;
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
#define OFF_T_BITWIDTH (unsigned int) (sizeof (off_t) * CHAR_BIT - 1)
|
||||
const off_t INVALID_OFFSET = (off_t) - 1;
|
||||
const off_t INVALID_OFFSET = (off_t) -1;
|
||||
const off_t OFFSETTYPE_MAX = ((off_t) 1 << (OFF_T_BITWIDTH - 1)) - 1;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
@ -121,7 +121,7 @@ mcview_move_up (mcview_t * view, off_t lines)
|
||||
if (last_row_length != 0 && cur_bol == view->dpy_start)
|
||||
new_offset = max (new_offset, (off_t) (view->dpy_start - last_row_length));
|
||||
else
|
||||
new_offset = max (new_offset, view->dpy_start - view->data_area.width);
|
||||
new_offset = max (new_offset, view->dpy_start - (off_t) view->data_area.width);
|
||||
}
|
||||
view->dpy_start = new_offset;
|
||||
}
|
||||
@ -164,12 +164,12 @@ mcview_move_down (mcview_t * view, off_t lines)
|
||||
{
|
||||
new_offset = mcview_eol (view, view->dpy_end);
|
||||
if (view->text_wrap_mode)
|
||||
new_offset = min (new_offset, view->dpy_end + view->data_area.width);
|
||||
new_offset = min (new_offset, view->dpy_end + (off_t) view->data_area.width);
|
||||
view->dpy_end = new_offset;
|
||||
|
||||
new_offset = mcview_eol (view, view->dpy_start);
|
||||
if (view->text_wrap_mode)
|
||||
new_offset = min (new_offset, view->dpy_start + view->data_area.width);
|
||||
new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width);
|
||||
view->dpy_start = new_offset;
|
||||
}
|
||||
view->dpy_end = last_byte;
|
||||
@ -181,7 +181,7 @@ mcview_move_down (mcview_t * view, off_t lines)
|
||||
{
|
||||
new_offset = mcview_eol (view, view->dpy_start);
|
||||
if (view->text_wrap_mode)
|
||||
new_offset = min (new_offset, view->dpy_start + view->data_area.width);
|
||||
new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width);
|
||||
view->dpy_start = new_offset;
|
||||
}
|
||||
}
|
||||
|
@ -175,9 +175,10 @@ mcview_display_nroff (mcview_t * view)
|
||||
tty_setcolor (SELECTED_COLOR);
|
||||
}
|
||||
|
||||
if (col >= view->dpy_text_column && col - view->dpy_text_column < width)
|
||||
if ((off_t) col >= view->dpy_text_column
|
||||
&& (off_t) col - view->dpy_text_column < (off_t) width)
|
||||
{
|
||||
widget_move (view, top + row, left + (col - view->dpy_text_column));
|
||||
widget_move (view, top + row, left + ((off_t) col - view->dpy_text_column));
|
||||
#ifdef HAVE_CHARSET
|
||||
if (utf8_display)
|
||||
{
|
||||
|
@ -152,9 +152,10 @@ mcview_display_text (mcview_t * view)
|
||||
if (view->search_start <= from && from < view->search_end)
|
||||
tty_setcolor (SELECTED_COLOR);
|
||||
|
||||
if ((col >= view->dpy_text_column) && (col - view->dpy_text_column < width))
|
||||
if (((off_t) col >= view->dpy_text_column)
|
||||
&& ((off_t) col - view->dpy_text_column < (off_t) width))
|
||||
{
|
||||
widget_move (view, top + row, left + (col - view->dpy_text_column));
|
||||
widget_move (view, top + row, left + ((off_t) col - view->dpy_text_column));
|
||||
#ifdef HAVE_CHARSET
|
||||
if (utf8_display)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user