On Wed, Feb 15, 2006 at 08:22:04PM +0100, Peter Korsgaard wrote:
> >>>>> "Andrew" == Andrew Lunn <[EMAIL PROTECTED]> writes:
>
> Andrew> Hi Peter
>
> Andrew> Please could you test this...
>
> Certainly..
>
> // define SHORT to be a two byte unsigned integer on the host
> -#define SHORT unsigned short
> +#define SHORT uint8_t
>
> This should ofcause be uint16_t.
Duh!
Thanks. Ive committed the fixed version.
Andrew
? fs/rom/current/support/mk_romfs
Index: fs/rom/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/rom/current/ChangeLog,v
retrieving revision 1.18
diff -u -r1.18 ChangeLog
--- fs/rom/current/ChangeLog 8 Jul 2005 20:13:44 -0000 1.18
+++ fs/rom/current/ChangeLog 15 Feb 2006 19:57:21 -0000
@@ -1,3 +1,9 @@
+2006-02-15 Andrew Lunn <[EMAIL PROTECTED]>
+ Peter Korsgaard <[EMAIL PROTECTED]>
+
+ * support/mk_romfs.c: Use stdint.h defined types so the code is
+ 64 bit clean. Fix compiler warnings.
+
2005-07-08 Andrew Lunn <[EMAIL PROTECTED]>
* cdl/romfs.cdl: Allow mk_romfs to be build even when the tests
Index: fs/rom/current/support/mk_romfs.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/fs/rom/current/support/mk_romfs.c,v
retrieving revision 1.7
diff -u -r1.7 mk_romfs.c
--- fs/rom/current/support/mk_romfs.c 14 Jul 2003 13:33:49 -0000 1.7
+++ fs/rom/current/support/mk_romfs.c 15 Feb 2006 19:57:22 -0000
@@ -63,6 +63,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
+#include <stdint.h>
//==========================================================================
//
@@ -71,10 +72,10 @@
//==========================================================================
// define LONG to be a four byte unsigned integer on the host
-#define LONG unsigned long
+#define LONG uint32_t
// define SHORT to be a two byte unsigned integer on the host
-#define SHORT unsigned short
+#define SHORT uint16_t
// All data files should be aligned to this sized boundary (minimum probably
32)
#define DATA_ALIGN 32
@@ -235,7 +236,7 @@
}
}
-static void outputlong( unsigned char *b, unsigned long w ) {
+static void outputlong( unsigned char *b, LONG w ) {
if ( bigendian ) {
b[0] = (w>>24) & 0xff;
b[1] = (w>>16) & 0xff;
@@ -249,7 +250,7 @@
}
}
-static void outputshort( unsigned char *b, unsigned short w ) {
+static void outputshort( unsigned char *b, SHORT w ) {
if ( bigendian ) {
b[0] = (w>> 8) & 0xff;
b[1] = (w ) & 0xff;
@@ -288,8 +289,8 @@
myrealloc( (void**)&parent_node->entry, (parent_node->size += this_size) );
g = (romfs_dirent *)((unsigned char *)parent_node->entry + start);
memset( (void*)g, '\0', this_size );
- outputlong( (char*)&g->node, node_num);
- outputlong( (char*)&g->next, parent_node->size);
+ outputlong( (unsigned char*)&g->node, node_num);
+ outputlong( (unsigned char*)&g->next, parent_node->size);
strcpy(g->name,name);
verb_printf( VERB_MAX, "\t%s --> node %d\n", name, node_num );
return (const char *)g->name;
@@ -503,13 +504,13 @@
static void WriteNode( int fd, node *np ) {
romfs_node anode;
char padhere[9];
- outputlong( (char*) &anode.mode, ConvertMode( np->st_mode ) );
- outputlong( (char*) &anode.nlink, np->nlink );
- outputshort((char*) &anode.uid, np->uid );
- outputshort((char*) &anode.gid, np->gid );
- outputlong( (char*) &anode.size, np->size );
- outputlong( (char*) &anode.ctime, np->ctime );
- outputlong( (char*) &anode.data_offset, np->offset );
+ outputlong( (unsigned char*) &anode.mode, ConvertMode( np->st_mode ) );
+ outputlong( (unsigned char*) &anode.nlink, np->nlink );
+ outputshort((unsigned char*) &anode.uid, np->uid );
+ outputshort((unsigned char*) &anode.gid, np->gid );
+ outputlong( (unsigned char*) &anode.size, np->size );
+ outputlong( (unsigned char*) &anode.ctime, np->ctime );
+ outputlong( (unsigned char*) &anode.data_offset, np->offset );
sprintf( padhere, "<%6d>", np->nodenum );
memcpy( anode.pad, padhere, 8 );
if ( dowrite && write( fd, (void*)&anode, sizeof(anode) ) != sizeof(anode)
)
@@ -538,10 +539,10 @@
romfs_disk header;
int wnodes;
- outputlong( (char*) &header.magic, ROMFS_MAGIC );
- outputlong( (char*) &header.nodecount, nodes );
- outputlong( (char*) &header.disksize, coffset );
- outputlong( (char*) &header.dev_id, 0x01020304 );
+ outputlong( (unsigned char*) &header.magic, ROMFS_MAGIC );
+ outputlong( (unsigned char*) &header.nodecount, nodes );
+ outputlong( (unsigned char*) &header.disksize, coffset );
+ outputlong( (unsigned char*) &header.dev_id, 0x01020304 );
strcpy( header.name, "ROMFS v1.0" );
if ( dowrite && write( fd, (void*)&header, sizeof(header) ) !=
sizeof(header) )
fatal_error(EXIT_WRITE, "Error writing ROMFS header: %s\n",
strerror(errno) );