various coverity-inspired fixes

. some strncpy/strcpy to strlcpy conversions
	. new <minix/param.h> to avoid including other minix headers
	  that have colliding definitions with library and commands code,
	  causing parse warnings
	. removed some dead code / assignments
This commit is contained in:
Ben Gras
2012-07-16 13:17:11 +02:00
parent 77dbd766c1
commit cbcdb838f1
26 changed files with 89 additions and 80 deletions

View File

@@ -4,7 +4,7 @@ NOOBJ= # defined
INCSDIR= /usr/include/minix
INCS+= dirent.h paths.h types.h
INCS+= dirent.h paths.h types.h param.h
.include "${NETBSDSRCDIR}/common/include/sys/Makefile.mount.inc"
.include "${NETBSDSRCDIR}/common/include/Makefile.termios.inc"

View File

@@ -72,12 +72,6 @@
#define FUTURE_CODE 0 /* new code to be activated + tested later */
#define TEMP_CODE 1 /* active code to be removed later */
/* Number of processes contained in the system image. */
#define NR_BOOT_PROCS (NR_TASKS + LAST_SPECIAL_PROC_NR + 1)
/* Process name length in the PM process table, including '\0'. */
#define PROC_NAME_LEN 16
/* Miscellaneous */
#define BYTE 0377 /* mask for 8 bits */
#define READING 0 /* copy data to user */

45
include/minix/param.h Normal file
View File

@@ -0,0 +1,45 @@
#ifndef _MINIX_PARAM_H
#define _MINIX_PARAM_H 1
#include <minix/com.h>
#include <minix/const.h>
/* Number of processes contained in the system image. */
#define NR_BOOT_PROCS (NR_TASKS + LAST_SPECIAL_PROC_NR + 1)
/* This is used to obtain system information through SYS_GETINFO. */
#define MAXMEMMAP 40
typedef struct kinfo {
/* Straight multiboot-provided info */
multiboot_info_t mbi;
multiboot_module_t module_list[MULTIBOOT_MAX_MODS];
multiboot_memory_map_t memmap[MAXMEMMAP]; /* free mem list */
phys_bytes mem_high_phys;
int mmap_size;
/* Multiboot-derived */
int mods_with_kernel; /* no. of mods incl kernel */
int kern_mod; /* which one is kernel */
/* Minix stuff, started at bootstrap phase */
int freepde_start; /* lowest pde unused kernel pde */
char param_buf[MULTIBOOT_PARAM_BUF_SIZE];
/* Minix stuff */
struct kmessages *kmess;
int do_serial_debug; /* system serial output */
int serial_debug_baud; /* serial baud rate */
int minix_panicing; /* are we panicing? */
vir_bytes user_sp; /* where does kernel want stack set */
vir_bytes user_end; /* upper proc limit */
vir_bytes vir_kern_start; /* kernel addrspace starts */
vir_bytes bootstrap_start, bootstrap_len;
struct boot_image boot_procs[NR_BOOT_PROCS];
int nr_procs; /* number of user processes */
int nr_tasks; /* number of kernel tasks */
char release[6]; /* kernel release number */
char version[6]; /* kernel version number */
} kinfo_t;
#endif

View File

@@ -10,9 +10,6 @@
#include <minix/types.h>
#endif
#include <minix/const.h>
#include <minix/com.h>
#include <stdint.h>
/* Type definitions. */
@@ -122,6 +119,8 @@ struct mem_range
phys_bytes mr_limit; /* Highest memory address in range */
};
#define PROC_NAME_LEN 16
/* List of boot-time processes set in kernel/table.c. */
struct boot_image {
int proc_nr; /* process number to use */
@@ -137,40 +136,6 @@ struct memory {
phys_bytes size;
};
/* This is used to obtain system information through SYS_GETINFO. */
#define MAXMEMMAP 40
typedef struct kinfo {
/* Straight multiboot-provided info */
multiboot_info_t mbi;
multiboot_module_t module_list[MULTIBOOT_MAX_MODS];
multiboot_memory_map_t memmap[MAXMEMMAP]; /* free mem list */
phys_bytes mem_high_phys;
int mmap_size;
/* Multiboot-derived */
int mods_with_kernel; /* no. of mods incl kernel */
int kern_mod; /* which one is kernel */
/* Minix stuff, started at bootstrap phase */
int freepde_start; /* lowest pde unused kernel pde */
char param_buf[MULTIBOOT_PARAM_BUF_SIZE];
/* Minix stuff */
struct kmessages *kmess;
int do_serial_debug; /* system serial output */
int serial_debug_baud; /* serial baud rate */
int minix_panicing; /* are we panicing? */
vir_bytes user_sp; /* where does kernel want stack set */
vir_bytes user_end; /* upper proc limit */
vir_bytes vir_kern_start; /* kernel addrspace starts */
vir_bytes bootstrap_start, bootstrap_len;
struct boot_image boot_procs[NR_BOOT_PROCS];
int nr_procs; /* number of user processes */
int nr_tasks; /* number of kernel tasks */
char release[6]; /* kernel release number */
char version[6]; /* kernel version number */
} kinfo_t;
#define STATICINIT(v, n) \
if(!(v)) { \
if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, NULL))) { \