diff --git a/rdasr.c b/rdasr.c index 332da5ae36cffb2dbecebbdadd2ccad0459fafcf..10bb240d673ed567a47a6400136bf782e00f2b6b 100644 --- a/rdasr.c +++ b/rdasr.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "version.h" #include "sysreg.h" @@ -81,7 +82,12 @@ int search(void) FILE *fp; if ((fp = fopen(TABLEPATH, "r")) == NULL) { - printf("%s: No such file or can not read!\n", TABLEPATH); + fprintf(stderr, "%s: No such file or can not read!\n\ + an register table you can find:\n\ + https://github.com/alibaba/system-register-tools/blob/main/registersv8.table\n\ + download and move this configure:\n\ + wget -o ~/.regstable\n\ + or move this file into '/root/' if you are root user!\n", TABLEPATH); return -1; } @@ -152,7 +158,7 @@ int test_all(void) FILE *fp; if ((fp = fopen(TABLEPATH, "r")) == NULL) { - printf("%s: No such file or can not read!\n", TABLEPATH); + fprintf(stderr, "%s: No such file or can not read!\n", TABLEPATH); return -1; } @@ -223,10 +229,10 @@ void parse(const char *regname) { int status; int op0, op1, cn, cm, op2; - unsigned int len = 0; + unsigned int len = strlen(regname); global_register = (struct register_t *)malloc(sizeof(struct register_t)); - global_register->length = strlen(regname); + global_register->length = len; global_register->name = strdup(regname); /* check the format of register name */ @@ -272,7 +278,7 @@ int main(int argc, char *argv[]) unsigned int highbit = 63, lowbit = 0; unsigned long arg; char *endarg; - char msr_file_name[64]; + char msr_file_name[NAME_MAX]; program = argv[0]; /* check the usage of program */ diff --git a/wrasr.c b/wrasr.c index 4520d24d04421a8af809ada597fcec3a49db5fa7..421a0f8ef0b116a0f22569efb36cf13ef5c122fe 100644 --- a/wrasr.c +++ b/wrasr.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "version.h" #include "sysreg.h" @@ -102,7 +103,13 @@ int search(void) FILE *fp; if ((fp = fopen(TABLEPATH, "r")) == NULL) { - printf("%s: No such file or can not read!\n", TABLEPATH); + fprintf(stderr, "%s: No such file or can not read!\n\ + an register table you can find:\n\ + https://github.com/alibaba/system-register-tools/blob/main/registersv8.table\n\ + download and move this configure:\n\ + wget -o ~/.regstable\n\ + or move this file into '/root/' if you are root user!\n", TABLEPATH); + return -1; } @@ -186,7 +193,7 @@ int main(int argc, char *argv[]) unsigned int highbit = 63, lowbit = 0; unsigned long arg; char *endarg; - char msr_file_name[64]; + char msr_file_name[NAME_MAX]; program = argv[0]; init();