diff --git a/arch/ppc/kernel.c b/arch/ppc/kernel.c index 2de283d..e3473d1 100644 --- a/arch/ppc/kernel.c +++ b/arch/ppc/kernel.c @@ -28,8 +28,6 @@ #define MEMORY_SIZE (256*1024) /* 256K ram for hosted system */ #define DICTIONARY_SIZE (512*1024) /* 128K for the dictionary */ -extern unsigned char *dict; -extern cell dicthead; static ucell *memory; /************************************************************************/ diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index e2ab5f6..6d737e3 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -87,7 +87,7 @@ entry( void ) } static void -setenv( char *env, char *value ) +setenv( const char *env, const char *value ) { push_str( value ); push_str( env ); @@ -97,7 +97,7 @@ setenv( char *env, char *value ) void arch_of_init( void ) { -#if USE_RTAS +#ifdef USE_RTAS phandle_t ph; #endif int autoboot; @@ -114,7 +114,7 @@ arch_of_init( void ) node_methods_init(); -#if USE_RTAS +#ifdef USE_RTAS if( !(ph=find_dev("/rtas")) ) printk("Warning: No /rtas node\n"); else { diff --git a/arch/sparc32/boot.c b/arch/sparc32/boot.c index b36b2b0..085861e 100644 --- a/arch/sparc32/boot.c +++ b/arch/sparc32/boot.c @@ -34,8 +34,8 @@ static void try_path(const char *path, char *param, const void *romvec) void boot(void) { - char *path = pop_fstr_copy(), *param, *oldpath = path; - char altpath[256]; + char *path = pop_fstr_copy(), *param, altpath[256]; + const char *oldpath = path; int unit = 0; const void *romvec; diff --git a/arch/sparc32/openprom.h b/arch/sparc32/openprom.h index 12fbe99..fe4cd8d 100644 --- a/arch/sparc32/openprom.h +++ b/arch/sparc32/openprom.h @@ -172,10 +172,10 @@ struct linux_romvec { struct linux_nodeops { int (*no_nextnode)(int node); int (*no_child)(int node); - int (*no_proplen)(int node, char *name); - int (*no_getprop)(int node, char *name, char *val); - int (*no_setprop)(int node, char *name, char *val, int len); - const char * (*no_nextprop)(int node, char *name); + int (*no_proplen)(int node, const char *name); + int (*no_getprop)(int node, const char *name, char *val); + int (*no_setprop)(int node, const char *name, char *val, int len); + const char * (*no_nextprop)(int node, const char *name); }; /* More fun PROM structures for device probing. */ diff --git a/arch/sparc32/romvec.c b/arch/sparc32/romvec.c index d05c372..a34b487 100644 --- a/arch/sparc32/romvec.c +++ b/arch/sparc32/romvec.c @@ -41,10 +41,10 @@ const char *obp_stdin_path, *obp_stdout_path; static int obp_nextnode(int node); static int obp_child(int node); -static int obp_proplen(int node, char *name); -static int obp_getprop(int node, char *name, char *val); -static int obp_setprop(int node, char *name, char *val, int len); -static const char *obp_nextprop(int node, char *name); +static int obp_proplen(int node, const char *name); +static int obp_getprop(int node, const char *name, char *val); +static int obp_setprop(int node, const char *name, char *val, int len); +static const char *obp_nextprop(int node, const char *name); static int obp_devread(int dev_desc, char *buf, int nbytes); static int obp_devseek(int dev_desc, int hi, int lo); @@ -85,7 +85,7 @@ static int obp_child(int node) return child; } -static int obp_proplen(int node, char *name) +static int obp_proplen(int node, const char *name) { int notfound; @@ -129,11 +129,11 @@ static int looks_like_string(char *str, int len) } #endif -static int obp_getprop(int node, char *name, char *value) +static int obp_getprop(int node, const char *name, char *value) { int notfound, found; int len; - char *str; + const char *str; if (!node) { DPRINTF("obp_getprop(0x0, %s) = -1\n", name); @@ -192,7 +192,7 @@ static int obp_getprop(int node, char *name, char *value) } } -static const char *obp_nextprop(int node, char *name) +static const char *obp_nextprop(int node, const char *name) { int found; @@ -224,7 +224,7 @@ static const char *obp_nextprop(int node, char *name) } static int obp_setprop(__attribute__((unused)) int node, - __attribute__((unused)) char *name, + __attribute__((unused)) const char *name, __attribute__((unused)) char *value, __attribute__((unused)) int len) { diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index 07ad728..14c27b3 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -44,17 +44,17 @@ void boot(void) } else { switch (boot_device) { case 'a': - path = "/obio/SUNW,fdtwo"; + path = strdup("/obio/SUNW,fdtwo"); break; case 'c': - path = "disk"; + path = strdup("disk"); break; default: case 'd': - path = "cdrom"; + path = strdup("cdrom"); break; case 'n': - path = "net"; + path = strdup("net"); break; } } diff --git a/drivers/esp.c b/drivers/esp.c index f3ef861..f1cdb84 100644 --- a/drivers/esp.c +++ b/drivers/esp.c @@ -41,7 +41,7 @@ struct esp_dma { typedef struct sd_private { unsigned int bs; - char *media_str; + const char *media_str; uint32_t sectors; uint8_t media; uint8_t id; @@ -182,7 +182,7 @@ read_capacity(esp_private_t *esp, sd_private_t *sd) static unsigned int inquiry(esp_private_t *esp, sd_private_t *sd) { - char *media = "UNKNOWN"; + const char *media = "UNKNOWN"; // Setup command = Inquiry memset(esp->buffer, 0, 7); diff --git a/drivers/ide.c b/drivers/ide.c index cb37ebd..c993fe8 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -157,7 +157,7 @@ ob_ide_400ns_delay(struct ide_drive *drive) } static void -ob_ide_error(struct ide_drive *drive, unsigned char stat, char *msg) +ob_ide_error(struct ide_drive *drive, unsigned char stat, const char *msg) { struct ide_channel *chan = drive->channel; unsigned char err; @@ -1285,8 +1285,8 @@ int ob_ide_init(void) { int i, j; - char * nodetemp_chan = "/pci/isa/ide%d"; - char * nodetemp = "/pci/isa/ide%d/%s"; + const char *nodetemp_chan = "/pci/isa/ide%d"; + const char *nodetemp = "/pci/isa/ide%d/%s"; char nodebuff[32]; phandle_t dnode; @@ -1336,7 +1336,7 @@ int ob_ide_init(void) printk("ide%d: [io ports 0x%x-0x%x,0x%x]\n", i, chan->io_regs[0], chan->io_regs[0] + 7, chan->io_regs[8]); for (j = 0; j < 2; j++) { struct ide_drive *drive = &chan->drives[j]; - char *media = "UNKNOWN"; + const char *media = "UNKNOWN"; if (!drive->present) continue; diff --git a/fs/grubfs/fsys_xfs.c b/fs/grubfs/fsys_xfs.c index f11ce00..ee0b9bf 100644 --- a/fs/grubfs/fsys_xfs.c +++ b/fs/grubfs/fsys_xfs.c @@ -342,9 +342,15 @@ next_dentry (xfs_ino_t *ino) { int namelen = 1; int toread; - static char *usual[2] = {".", ".."}; + static char *usual[2]; static xfs_dir2_sf_entry_t *sfe; - char *name = usual[0]; + char *name; + + if (!usual[0]) { + usual[0] = strdup("."); + usual[1] = strdup(".."); + } + name = usual[0]; if (xfs.dirpos >= xfs.dirmax) { if (xfs.forw == 0) diff --git a/fs/grubfs/grubfs_fs.c b/fs/grubfs/grubfs_fs.c index 03679ab..1633759 100644 --- a/fs/grubfs/grubfs_fs.c +++ b/fs/grubfs/grubfs_fs.c @@ -47,7 +47,7 @@ void (*disk_read_func) (int, int, int); /************************************************************************/ typedef struct fsys_entry { - char *name; + const char *name; int (*mount_func) (void); int (*read_func) (char *buf, int len); int (*dir_func) (char *dirname); @@ -221,7 +221,7 @@ close_fs( fs_ops_t *fs ) /* callers responsibility to call free(fs) */ } -static char * +static const char * grubfs_get_fstype( fs_ops_t *fs ) { grubfs_t *gfs = (grubfs_t*)fs->fs_data; diff --git a/fs/hfsplus/hfsp_fs.c b/fs/hfsplus/hfsp_fs.c index b916ee0..f247299 100644 --- a/fs/hfsplus/hfsp_fs.c +++ b/fs/hfsplus/hfsp_fs.c @@ -67,7 +67,9 @@ search_files( record *par, int recursive, match_proc_t proc, const void *match_d } while( ret && !record_next(&r) ); if( !ret && pt ) { - char name[256], *s2 = t.path ? t.path : ""; + char name[256]; + const char *s2 = t.path ? t.path : ""; + unicode_uni2asc( name, &r.key.name, sizeof(name)); pt->rec = t.rec; @@ -359,7 +361,7 @@ vol_name( fs_ops_t *fs, char *buf, int size ) return get_hfs_vol_name( fs->fd, buf, size ); } -static char * +static const char * get_fstype( fs_ops_t *fs ) { return ("HFS+"); diff --git a/include/openbios/fs.h b/include/openbios/fs.h index ffc6ee5..442758b 100644 --- a/include/openbios/fs.h +++ b/include/openbios/fs.h @@ -43,7 +43,7 @@ struct fs_ops { int (*lseek)( file_desc_t *file, off_t offset, int whence ); char *(*get_path)( file_desc_t *file, char *buf, int len ); - char *(*get_fstype)( fs_ops_t *fs ); + const char *(*get_fstype)( fs_ops_t *fs ); }; extern fs_ops_t *fs_open( int fs_type, int fd ); diff --git a/include/openbios/kernel.h b/include/openbios/kernel.h index 5a7795f..fac9bf3 100644 --- a/include/openbios/kernel.h +++ b/include/openbios/kernel.h @@ -25,7 +25,7 @@ extern volatile int runforth; extern int enterforth( xt_t xt ); extern void panic(const char *error) __attribute__ ((noreturn)); -extern xt_t findword(char *s1); +extern xt_t findword(const char *s1); extern void modules_init( void ); /* arch kernel hooks */ diff --git a/kernel/bootstrap.c b/kernel/bootstrap.c index 4fdd751..5595c6e 100644 --- a/kernel/bootstrap.c +++ b/kernel/bootstrap.c @@ -53,7 +53,7 @@ unsigned long base_address; /* include path handling */ typedef struct include_path include; struct include_path { - char *path; + const char *path; include *next; }; @@ -137,7 +137,7 @@ static void relocation_table(unsigned char * dict_one, unsigned char *dict_two, relocation_address=reloc_table; } -static void write_dictionary(char *filename) +static void write_dictionary(const char *filename) { FILE *f; unsigned char *write_data, *walk_data; @@ -375,7 +375,7 @@ static void paddict(ucell align) * generic forth word creator function. */ -static void fcreate(char *word, ucell cfaval) +static void fcreate(const char *word, ucell cfaval) { if (strlen(word) == 0) { printk("WARNING: tried to create unnamed word.\n"); @@ -395,20 +395,20 @@ static void fcreate(char *word, ucell cfaval) } -static ucell *buildvariable(char *name, cell defval) +static ucell *buildvariable(const char *name, cell defval) { fcreate(name, DOVAR); /* see dict.h for DOVAR and other CFA ids */ writecell(defval); return (ucell *) (dict + dicthead - sizeof(cell)); } -static void buildconstant(char *name, cell defval) +static void buildconstant(const char *name, cell defval) { fcreate(name, DOCON); /* see dict.h for DOCON and other CFA ids */ writecell(defval); } -static void builddefer(char *name) +static void builddefer(const char *name) { fcreate(name, DODFR); /* see dict.h for DODFR and other CFA ids */ writecell((ucell)0); diff --git a/kernel/dict.c b/kernel/dict.c index 3bf0748..47dffbf 100644 --- a/kernel/dict.c +++ b/kernel/dict.c @@ -68,7 +68,7 @@ static int to_lower(int c) /* fstrcmp - compare null terminated string with forth string. */ -static int fstrcmp(char *s1, ucell fstr) +static int fstrcmp(const char *s1, ucell fstr) { char *s2 = (char*)cell2pointer(fstr); while (*s1) { @@ -84,7 +84,7 @@ static int fstrcmp(char *s1, ucell fstr) * word. */ -xt_t findword(char *s1) +xt_t findword(const char *s1) { ucell tmplfa, len; diff --git a/modules/nvram.c b/modules/nvram.c index fd029dc..9125ade 100644 --- a/modules/nvram.c +++ b/modules/nvram.c @@ -110,7 +110,7 @@ create_free_part( char *ptr, int size ) } static int -create_nv_part( int signature, char *name, int size ) +create_nv_part( int signature, const char *name, int size ) { nvpart_t *p = NULL; int fs; diff --git a/modules/video.c b/modules/video.c index 6c48a59..509e205 100644 --- a/modules/video.c +++ b/modules/video.c @@ -174,7 +174,7 @@ set_color( int ind, ulong color ) #ifdef CONFIG_MOL if( video.fb.depth == 8 ) OSI_SetColor( ind, color ); -#elif CONFIG_SPARC32 +#elif defined(CONFIG_SPARC32) if( video.fb.depth == 8 ) { dac[0] = ind << 24; dac[1] = ((color >> 16) & 0xff) << 24; // Red