From: Randy Dunlap <[EMAIL PROTECTED]>
* clean up code, gcc warnings
(try compilation with "-Wall -Wp,-D_FORTIFY_SOURCE=2")
Builds cleanly on x86_32 and x86_64.
This was the first set of warnings. Correcting some of these lead to
other warnings (which are not listed here).
Some of these (signed char/unsigned char/char) could have been fixed in
other ways. I basically forced all of these to unsigned char.
mkfs.cramfs.c:211: warning: pointer targets in passing argument 2 of
'MD5Update' differ in signedness
mkfs.cramfs.c:336: warning: format '%u' expects type 'unsigned int', but
argument 4 has type 'size_t'
mkfs.cramfs.c:355: warning: pointer targets in assignment differ in signedness
mkfs.cramfs.c:448: warning: pointer targets in passing argument 1 of
'__builtin___strncpy_chk' differ in signedness
mkfs.cramfs.c:448: warning: pointer targets in passing argument 1 of
'__strncpy_ichk' differ in signedness
mkfs.cramfs.c:450: warning: pointer targets in passing argument 1 of
'__builtin___strncpy_chk' differ in signedness
mkfs.cramfs.c:450: warning: pointer targets in passing argument 1 of
'__strncpy_ichk' differ in signedness
mkfs.cramfs.c:490: warning: pointer targets in passing argument 1 of 'strlen'
differ in signedness
mkfs.cramfs.c:620: warning: pointer targets in passing argument 1 of 'compress'
differ in signedness
mkfs.cramfs.c:620: warning: pointer targets in passing argument 3 of 'compress'
differ in signedness
mkfs.cramfs.c:671: warning: pointer targets in passing argument 3 of
'do_compress' differ in signedness
mkfs.cramfs.c:824: warning: format '%Ld' expects type 'long long int', but
argument 4 has type 'loff_t'
mkfs.cramfs.c:872: warning: format '%d' expects type 'int', but argument 3 has
type 'ssize_t'
mkfs.cramfs.c:880: warning: format '%d' expects type 'int', but argument 3 has
type 'ssize_t'
mkfs.cramfs.c:885: warning: format '%d' expects type 'int', but argument 3 has
type 'long unsigned int'
mkfs.cramfs.c:889: warning: pointer targets in passing argument 2 of 'crc32'
differ in signedness
mkfs.cramfs.c:896: warning: format '%Ld' expects type 'long long int', but
argument 4 has type 'loff_t'
mkfs.cramfs.c:896: warning: format '%d' expects type 'int', but argument 5 has
type 'ssize_t'
mkfs.cramfs.c:909: warning: format '%d' expects type 'int', but argument 4 has
type 'ssize_t'
mkfs.cramfs.c:909: warning: format '%d' expects type 'int', but argument 5 has
type 'ssize_t'
Signed-off-by: Randy Dunlap <[EMAIL PROTECTED]>
---
disk-utils/mkfs.cramfs.c | 60 +++++++++++++++++++++++------------------------
1 file changed, 30 insertions(+), 30 deletions(-)
--- util-linux-ng-2.13.orig/disk-utils/mkfs.cramfs.c
+++ util-linux-ng-2.13/disk-utils/mkfs.cramfs.c
@@ -154,17 +154,17 @@ xmalloc (size_t size) {
return t;
}
-static char *
+static unsigned char *
do_mmap(char *path, unsigned int size, unsigned int mode){
int fd;
- char *start;
+ unsigned char *start;
if (!size)
return NULL;
if (S_ISLNK(mode)) {
start = xmalloc(size);
- if (readlink(path, start, size) < 0) {
+ if (readlink(path, (char *)start, size) < 0) {
perror(path);
warn_skip = 1;
start = NULL;
@@ -190,7 +190,7 @@ do_mmap(char *path, unsigned int size, u
}
static void
-do_munmap(char *start, unsigned int size, unsigned int mode){
+do_munmap(unsigned char *start, unsigned int size, unsigned int mode){
if (S_ISLNK(mode))
free(start);
else
@@ -201,7 +201,7 @@ do_munmap(char *start, unsigned int size
static void
mdfile(struct entry *e) {
MD5_CTX ctx;
- char *start;
+ unsigned char *start;
start = do_mmap(e->path, e->size, e->mode);
if (start == NULL) {
@@ -221,7 +221,7 @@ mdfile(struct entry *e) {
but just to be sure, do the comparison */
static int
identical_file(struct entry *e1, struct entry *e2){
- char *start1, *start2;
+ unsigned char *start1, *start2;
int equal;
start1 = do_mmap(e1->path, e1->size, e1->mode);
@@ -334,7 +334,7 @@ static unsigned int parse_directory(stru
namelen = strlen(dirent->d_name);
if (namelen > MAX_INPUT_NAMELEN) {
fprintf(stderr,
- _("Very long (%u bytes) filename `%s' found.\n"
+ _("Very long (%zu bytes) filename `%s' found.\n"
" Please increase MAX_INPUT_NAMELEN in "
"mkcramfs.c and recompile. Exiting.\n"),
namelen, dirent->d_name);
@@ -352,7 +352,7 @@ static unsigned int parse_directory(stru
perror(NULL);
exit(8);
}
- entry->name = strdup(dirent->d_name);
+ entry->name = (unsigned char *)strdup(dirent->d_name);
if (!entry->name) {
perror(NULL);
exit(8);
@@ -420,7 +420,7 @@ static unsigned int parse_directory(stru
}
/* Returns sizeof(struct cramfs_super), which includes the root inode. */
-static unsigned int write_superblock(struct entry *root, char *base, int size)
+static unsigned int write_superblock(struct entry *root, unsigned char *base,
int size)
{
struct cramfs_super *super = (struct cramfs_super *) base;
unsigned int offset = sizeof(struct cramfs_super) + image_length;
@@ -445,9 +445,9 @@ static unsigned int write_superblock(str
memset(super->name, 0x00, sizeof(super->name));
if (opt_name)
- strncpy(super->name, opt_name, sizeof(super->name));
+ strncpy((char *)super->name, opt_name, sizeof(super->name));
else
- strncpy(super->name, "Compressed", sizeof(super->name));
+ strncpy((char *)super->name, "Compressed", sizeof(super->name));
super->root.mode = root->mode;
super->root.uid = root->uid;
@@ -458,7 +458,7 @@ static unsigned int write_superblock(str
return offset;
}
-static void set_data_offset(struct entry *entry, char *base, unsigned long
offset)
+static void set_data_offset(struct entry *entry, unsigned char *base, unsigned
long offset)
{
struct cramfs_inode *inode = (struct cramfs_inode *) (base +
entry->dir_offset);
if (offset >= (1 << (2 + CRAMFS_OFFSET_WIDTH))) {
@@ -474,7 +474,7 @@ static void set_data_offset(struct entry
* entries, using a stack to remember the directories
* we've seen.
*/
-static unsigned int write_directory_structure(struct entry *entry, char *base,
unsigned int offset)
+static unsigned int write_directory_structure(struct entry *entry, unsigned
char *base, unsigned int offset)
{
int stack_entries = 0;
int stack_size = 64;
@@ -487,7 +487,7 @@ static unsigned int write_directory_stru
while (entry) {
struct cramfs_inode *inode =
(struct cramfs_inode *) (base + offset);
- size_t len = strlen(entry->name);
+ size_t len = strlen((const char *)entry->name);
entry->dir_offset = offset;
@@ -560,7 +560,7 @@ static unsigned int write_directory_stru
return offset;
}
-static int is_zero(char const *begin, unsigned len)
+static int is_zero(unsigned char const *begin, unsigned len)
{
if (opt_holes)
/* Returns non-zero iff the first LEN bytes from BEGIN are
@@ -590,12 +590,12 @@ static int is_zero(char const *begin, un
* have gotten here in the first place.
*/
static unsigned int
-do_compress(char *base, unsigned int offset, char const *name,
+do_compress(unsigned char *base, unsigned int offset, unsigned char const
*name,
char *path, unsigned int size, unsigned int mode)
{
unsigned long original_size, original_offset, new_size, blocks, curr;
int change;
- char *p, *start;
+ Bytef *p, *start;
/* get uncompressed data */
start = do_mmap(path, size, mode);
@@ -611,13 +611,13 @@ do_compress(char *base, unsigned int off
total_blocks += blocks;
do {
- unsigned long len = 2 * blksize;
- unsigned int input = size;
+ uLongf len = 2 * blksize;
+ uLongf input = size;
if (input > blksize)
input = blksize;
size -= input;
if (!is_zero (p, input)) {
- compress(base + curr, &len, p, input);
+ compress((Bytef *)(base + curr), &len, p, input);
curr += len;
}
p += input;
@@ -656,7 +656,7 @@ do_compress(char *base, unsigned int off
* regfile).
*/
static unsigned int
-write_data(struct entry *entry, char *base, unsigned int offset) {
+write_data(struct entry *entry, unsigned char *base, unsigned int offset) {
struct entry *e;
for (e = entry; e; e = e->next) {
@@ -676,7 +676,7 @@ write_data(struct entry *entry, char *ba
return offset;
}
-static unsigned int write_file(char *file, char *base, unsigned int offset)
+static unsigned int write_file(char *file, unsigned char *base, unsigned int
offset)
{
int fd;
char *buf;
@@ -725,7 +725,7 @@ int main(int argc, char **argv)
{
struct stat st; /* used twice... */
struct entry *root_entry;
- char *rom_image;
+ unsigned char *rom_image;
ssize_t offset, written;
int fd;
/* initial guess (upper-bound) of required filesystem size */
@@ -825,7 +825,7 @@ int main(int argc, char **argv)
_("warning: guestimate of required size (upper bound) "
"is %LdMB, but maximum image size is %uMB. "
"We might die prematurely.\n"),
- fslen_ub >> 20,
+ (long long)fslen_ub >> 20,
fslen_max >> 20);
fslen_ub = fslen_max;
}
@@ -869,7 +869,7 @@ int main(int argc, char **argv)
offset = write_directory_structure(root_entry->child, rom_image,
offset);
if (verbose)
- printf(_("Directory data: %d bytes\n"), offset);
+ printf(_("Directory data: %zd bytes\n"), offset);
offset = write_data(root_entry, rom_image, offset);
@@ -877,12 +877,12 @@ int main(int argc, char **argv)
losetup works. */
offset = ((offset - 1) | (blksize - 1)) + 1;
if (verbose)
- printf(_("Everything: %d kilobytes\n"), offset >> 10);
+ printf(_("Everything: %zd kilobytes\n"), offset >> 10);
/* Write the superblock now that we can fill in all of the fields. */
write_superblock(root_entry, rom_image+opt_pad, offset);
if (verbose)
- printf(_("Super block: %d bytes\n"),
+ printf(_("Super block: %zd bytes\n"),
sizeof(struct cramfs_super));
/* Put the checksum in. */
@@ -895,8 +895,8 @@ int main(int argc, char **argv)
if (fslen_ub < offset) {
fprintf(stderr,
_("not enough space allocated for ROM image "
- "(%Ld allocated, %d used)\n"),
- fslen_ub, offset);
+ "(%Ld allocated, %zd used)\n"),
+ (long long)fslen_ub, offset);
exit(8);
}
@@ -906,7 +906,7 @@ int main(int argc, char **argv)
exit(8);
}
if (offset != written) {
- fprintf(stderr, _("ROM image write failed (%d %d)\n"),
+ fprintf(stderr, _("ROM image write failed (%zd %zd)\n"),
written, offset);
exit(8);
}
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html