More patches from pbatard to reduce warnings, etc.

This commit is contained in:
R. Bernstein
2012-03-03 20:11:14 -05:00
parent d0018220cc
commit 2022037807
13 changed files with 134 additions and 84 deletions

View File

@@ -31,7 +31,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in /* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */ say opensolaris. */
#include "filemode.h" #include "portable.h"
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/iso9660.h> #include <cdio/iso9660.h>

View File

@@ -37,7 +37,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in /* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */ say opensolaris. */
#include "filemode.h" #include "portable.h"
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>

View File

@@ -28,7 +28,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in /* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */ say opensolaris. */
#include "filemode.h" #include "portable.h"
#ifdef HAVE_STDIO_H #ifdef HAVE_STDIO_H
#include <stdio.h> #include <stdio.h>

View File

@@ -49,7 +49,7 @@ EXTRA_DIST = image/Makefile \
FreeBSD/Makefile MSWindows/Makefile \ FreeBSD/Makefile MSWindows/Makefile \
libcdio.sym libcdio.sym
noinst_HEADERS = cdio_assert.h cdio_private.h filemode.h noinst_HEADERS = cdio_assert.h cdio_private.h filemode.h portable.h
libcdio_sources = \ libcdio_sources = \
_cdio_generic.c \ _cdio_generic.c \

View File

@@ -1,5 +1,8 @@
/* /*
Copyright (C) 2006, 2008, 2011 Rocky Bernstein <rocky@gnu.org> filemode.h -- file modes common definitions
Copyright (C) 2005, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1985, 1990, 1993, 1998-2000 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -15,62 +18,117 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* #ifndef __FILEMODE_H__
This file contains definitions to fill in for differences or #define __FILEMODE_H__
deficiencies to OS or compiler irregularities. If this file is
included other routines can be more portable.
*/
#ifndef __CDIO_PORTABLE_H__
#define __CDIO_PORTABLE_H__
#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__) #ifdef HAVE_SYS_STAT_H
# include "config.h" #include <sys/stat.h>
# define __CDIO_CONFIG_H__ 1
#endif #endif
#if !defined(HAVE_FTRUNCATE) #ifndef S_IRUSR
# if defined ( WIN32 ) # ifdef S_IREAD
# define ftruncate chsize # define S_IRUSR S_IREAD
# else
# define S_IRUSR 00400
# endif # endif
#endif /*HAVE_FTRUNCATE*/
#if !defined(HAVE_SNPRINTF)
# if defined ( MSVC )
# define snprintf _snprintf
# endif
#endif /*HAVE_SNPRINTF*/
#if !defined(HAVE_VSNPRINTF)
# if defined ( MSVC )
# define snprintf _vsnprintf
# endif
#endif /*HAVE_SNPRINTF*/
#if !defined(HAVE_DRAND48) && defined(HAVE_RAND)
# define drand48() (rand() / (double)RAND_MAX)
#endif #endif
#ifdef MSVC #ifndef S_IWUSR
# include <io.h> # ifdef S_IWRITE
# define S_IWUSR S_IWRITE
# ifndef S_ISBLK # else
# define _S_IFBLK 0060000 /* Block Special */ # define S_IWUSR 00200
# define S_ISBLK(x) (x & _S_IFBLK)
# endif # endif
# ifndef S_ISCHR
# define _S_IFCHR 0020000 /* character special */
# define S_ISCHR(x) (x & _S_IFCHR)
# endif
#endif /*MSVC*/
#ifdef HAVE_MEMSET
# define BZERO(ptr, size) memset(ptr, 0, size)
#elif HAVE_BZERO
# define BZERO(ptr, size) bzero(ptr, size)
#else
#error You need either memset or bzero
#endif #endif
#endif /* __CDIO_PORTABLE_H__ */ #ifndef S_IXUSR
# ifdef S_IEXEC
# define S_IXUSR S_IEXEC
# else
# define S_IXUSR 00100
# endif
#endif
#ifndef S_IRGRP
# define S_IRGRP (S_IRUSR >> 3)
#endif
#ifndef S_IWGRP
# define S_IWGRP (S_IWUSR >> 3)
#endif
#ifndef S_IXGRP
# define S_IXGRP (S_IXUSR >> 3)
#endif
#ifndef S_IROTH
# define S_IROTH (S_IRUSR >> 6)
#endif
#ifndef S_IWOTH
# define S_IWOTH (S_IWUSR >> 6)
#endif
#ifndef S_IXOTH
# define S_IXOTH (S_IXUSR >> 6)
#endif
#ifdef STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
#endif /* STAT_MACROS_BROKEN. */
#if !defined S_IFBLK && defined _WIN32
# define S_IFBLK 0x3000
#endif
#if !defined S_IFIFO && defined _WIN32
# define S_IFIFO 0x1000
#endif
#if !defined S_ISBLK && defined S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined S_ISCHR && defined S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined S_ISDIR && defined S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined S_ISREG && defined S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined S_ISFIFO && defined S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined HAVE_S_ISLNK
# if !defined S_ISLNK && defined S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) ((void)m, 0)
# endif
#endif
#if !defined HAVE_S_ISSOCK
# if !defined S_ISSOCK && defined S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) ((void)m, 0)
# endif
#endif
#if !defined S_ISMPB && defined S_IFMPB /* V7 */
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
#endif
#if !defined S_ISNWK && defined S_IFNWK /* HP/UX */
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
#if !defined S_ISDOOR && defined S_IFDOOR /* Solaris 2.5 and up */
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
#endif
#if !defined S_ISCTG && defined S_IFCTG /* MassComp */
# define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
#endif
#endif /* __FILEMODE_H__ */

View File

@@ -59,7 +59,7 @@
#include <ctype.h> #include <ctype.h>
#include "filemode.h" #include "portable.h"
/* reader */ /* reader */
#define DEFAULT_CDIO_DEVICE "videocd.bin" #define DEFAULT_CDIO_DEVICE "videocd.bin"

View File

@@ -62,7 +62,7 @@
#include <ctype.h> #include <ctype.h>
#include "filemode.h" #include "portable.h"
/* reader */ /* reader */

View File

@@ -178,8 +178,8 @@ static bool
parse_nrg (_img_private_t *p_env, const char *psz_nrg_name, parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
const cdio_log_level_t log_level) const cdio_log_level_t log_level)
{ {
long unsigned int footer_start; off_t footer_start;
long unsigned int size; off_t size;
char *footer_buf = NULL; char *footer_buf = NULL;
if (!p_env) return false; if (!p_env) return false;
size = cdio_stream_stat (p_env->gen.data_source); size = cdio_stream_stat (p_env->gen.data_source);
@@ -209,11 +209,11 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
cdio_assert ((size - footer_start) <= 4096); cdio_assert ((size - footer_start) <= 4096);
footer_buf = calloc(1, size - footer_start); footer_buf = calloc(1, (size_t)(size - footer_start));
cdio_stream_seek (p_env->gen.data_source, footer_start, SEEK_SET); cdio_stream_seek (p_env->gen.data_source, footer_start, SEEK_SET);
cdio_stream_read (p_env->gen.data_source, footer_buf, cdio_stream_read (p_env->gen.data_source, footer_buf,
size - footer_start, 1); (size_t)(size - footer_start), 1);
} }
{ {
int pos = 0; int pos = 0;
@@ -844,9 +844,9 @@ _lseek_nrg (void *p_user_data, off_t offset, int whence)
track_info_t *this_track=&(p_env->tocent[i]); track_info_t *this_track=&(p_env->tocent[i]);
p_env->pos.index = i; p_env->pos.index = i;
if ( (this_track->sec_count*this_track->datasize) >= offset) { if ( (this_track->sec_count*this_track->datasize) >= offset) {
int blocks = offset / this_track->datasize; int blocks = (int) (offset / this_track->datasize);
int rem = offset % this_track->datasize; int rem = (int) (offset % this_track->datasize);
int block_offset = blocks * this_track->blocksize; off_t block_offset = blocks * this_track->blocksize;
real_offset += block_offset + rem; real_offset += block_offset + rem;
p_env->pos.buff_offset = rem; p_env->pos.buff_offset = rem;
p_env->pos.lba += blocks; p_env->pos.lba += blocks;

View File

@@ -1,5 +1,6 @@
/* /*
Copyright (C) 2003, 2004, 2008, 2011 Rocky Bernstein <rocky@gnu.org> Copyright (C) 2003, 2004, 2008, 2011, 2012
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@@ -27,7 +28,7 @@
#include <cdio/logging.h> #include <cdio/logging.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "filemode.h" #include "portable.h"
static const char _rcsid[] = "$Id: logging.c,v 1.2 2008/04/22 15:29:12 karl Exp $"; static const char _rcsid[] = "$Id: logging.c,v 1.2 2008/04/22 15:29:12 karl Exp $";

View File

@@ -26,6 +26,7 @@
#include <cdio/util.h> #include <cdio/util.h>
#include <cdio/logging.h> #include <cdio/logging.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include "portable.h"
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H

View File

@@ -1,7 +1,5 @@
/* /*
$Id: iso-read.c,v 1.16 2008/06/19 15:44:19 flameeyes Exp $ Copyright (C) 2004, 2005, 2006, 2008, 2012 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -20,7 +18,7 @@
/* Program to read ISO-9660 images. */ /* Program to read ISO-9660 images. */
#include "util.h" #include "util.h"
#include "filemode.h" #include "portable.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"

View File

@@ -17,17 +17,7 @@
*/ */
/* Tests reading ISO 9660 info from a CD. */ /* Tests reading ISO 9660 info from a CD. */
#include "portable.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
# define __CDIO_CONFIG_H__ 1
#endif
#include "filemode.h"
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <cdio/cd_types.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
@@ -47,9 +37,10 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <cdio/cdio.h>
#endif #include <cdio/iso9660.h>
#include <cdio/cd_types.h>
#define SKIP_TEST_RC 77 #define SKIP_TEST_RC 77

View File

@@ -17,6 +17,7 @@
*/ */
/* Tests reading ISO 9660 info from an ISO 9660 image. */ /* Tests reading ISO 9660 info from an ISO 9660 image. */
#include "portable.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"