Skip to content
Snippets Groups Projects
Commit 413e2175 authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

remove atoi/atof and added them, and atol, to the BAN_UNSAFE_FUNCTIONS list

parent 6bdd8144
No related branches found
No related tags found
No related merge requests found
...@@ -905,6 +905,12 @@ void Print_trace(void); ...@@ -905,6 +905,12 @@ void Print_trace(void);
#define strncpy ___DUMMY #define strncpy ___DUMMY
#undef strncat #undef strncat
#define strncat ___DUMMY #define strncat ___DUMMY
#undef atof
#define strncat ___DUMMY
#undef atoi
#define strncat ___DUMMY
#undef atol
#define strncat ___DUMMY
#endif // BAN_UNSAFE_FUNCTIONS #endif // BAN_UNSAFE_FUNCTIONS
......
...@@ -118,10 +118,10 @@ static int binary_c_main(int argc, ...@@ -118,10 +118,10 @@ static int binary_c_main(int argc,
{ {
printf("You must run binary_c with four arguments (X,Z,T,rho) to test the opacity table\n"); printf("You must run binary_c with four arguments (X,Z,T,rho) to test the opacity table\n");
} }
op.H = atof(argv[1]); op.H = strtod(argv[1],NULL);
op.Z = atof(argv[2]); op.Z = strtod(argv[2],NULL);
op.temperature = atof(argv[3]); op.temperature = strtod(argv[3],NULL);
op.density = atof(argv[4]); op.density = strtod(argv[4],NULL);
double kap_pac = opacity_paczynski(stardata,&op,OPACITY_ALGORITHM_PACZYNSKI); double kap_pac = opacity_paczynski(stardata,&op,OPACITY_ALGORITHM_PACZYNSKI);
double kap_fop = opacity_ferguson_opal(stardata,&op,OPACITY_ALGORITHM_FERGUSON_OPAL); double kap_fop = opacity_ferguson_opal(stardata,&op,OPACITY_ALGORITHM_FERGUSON_OPAL);
......
...@@ -10,8 +10,7 @@ static char * arg_variable_default_string( ...@@ -10,8 +10,7 @@ static char * arg_variable_default_string(
void binary_c_warmup_cpu(ARG_SUBROUTINE_DECLARATION) void binary_c_warmup_cpu(ARG_SUBROUTINE_DECLARATION)
{ {
(*c)++; (*c)++;
const int secs = atoi(argv[*c]); const int secs = (int) strtol(argv[*c],NULL,10);
printf("secs warmup %d\n",secs);
if(secs!=0)warmup_cpu(stardata,secs); if(secs!=0)warmup_cpu(stardata,secs);
} }
...@@ -389,10 +388,10 @@ void No_return dumpversion(ARG_SUBROUTINE_DECLARATION) ...@@ -389,10 +388,10 @@ void No_return dumpversion(ARG_SUBROUTINE_DECLARATION)
void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION) void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION)
{ {
(*c)++; (*c)++;
int n MAYBE_UNUSED =atoi(argv[*c]); Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10);
(*c)++; (*c)++;
#ifdef NUCSYN #ifdef NUCSYN
double f=atof(argv[*c]); double f = strtod(argv[*c],NULL);
if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->initial_abundance_multiplier[n]=f; if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->initial_abundance_multiplier[n]=f;
#endif #endif
} }
...@@ -400,10 +399,10 @@ void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION) ...@@ -400,10 +399,10 @@ void set_init_abund_mult(ARG_SUBROUTINE_DECLARATION)
void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION) void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION)
{ {
(*c)++; (*c)++;
int n MAYBE_UNUSED =atoi(argv[*c]); Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10);
(*c)++; (*c)++;
#ifdef NUCSYN #ifdef NUCSYN
double f=atof(argv[*c]); double f = strtod(argv[*c],NULL);
f = pow(10.0,f); f = pow(10.0,f);
if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->initial_abundance_multiplier[n]=f; if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->initial_abundance_multiplier[n]=f;
//fprintf(stderr,"SET MULT %d to %g\n",n,f); //fprintf(stderr,"SET MULT %d to %g\n",n,f);
...@@ -413,10 +412,10 @@ void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION) ...@@ -413,10 +412,10 @@ void set_init_abund_dex(ARG_SUBROUTINE_DECLARATION)
void set_init_abund(ARG_SUBROUTINE_DECLARATION) void set_init_abund(ARG_SUBROUTINE_DECLARATION)
{ {
(*c)++; (*c)++;
int n MAYBE_UNUSED =atoi(argv[*c]); Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10);
(*c)++; (*c)++;
#ifdef NUCSYN #ifdef NUCSYN
double X=atof(argv[*c]); double X = strtod(argv[*c],NULL);
if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->the_initial_abundances[n]=X; if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->the_initial_abundances[n]=X;
#endif #endif
} }
...@@ -424,10 +423,10 @@ void set_init_abund(ARG_SUBROUTINE_DECLARATION) ...@@ -424,10 +423,10 @@ void set_init_abund(ARG_SUBROUTINE_DECLARATION)
void set_third_dup_multiplier(ARG_SUBROUTINE_DECLARATION) void set_third_dup_multiplier(ARG_SUBROUTINE_DECLARATION)
{ {
(*c)++; (*c)++;
int n MAYBE_UNUSED =atoi(argv[*c]); Isotope n MAYBE_UNUSED = (Isotope)strtol(argv[*c],NULL,10);
(*c)++; (*c)++;
#if defined (NUCSYN) && defined(THIRD_DREDGE_UP) && defined(NUCSYN_THIRD_DREDGE_UP_MULTIPLIERS) #if defined (NUCSYN) && defined(THIRD_DREDGE_UP) && defined(NUCSYN_THIRD_DREDGE_UP_MULTIPLIERS)
double X=atof(argv[*c]); double X = strtod(argv[*c],NULL);
if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->third_dup_multiplier[n]=X; if(n<ISOTOPE_ARRAY_SIZE) stardata->preferences->third_dup_multiplier[n]=X;
preferences->boost_third_dup=TRUE; preferences->boost_third_dup=TRUE;
#endif #endif
......
...@@ -390,10 +390,10 @@ void version(struct stardata_t * RESTRICT const stardata) ...@@ -390,10 +390,10 @@ void version(struct stardata_t * RESTRICT const stardata)
* This defaults to 100ms, but can be set using the * This defaults to 100ms, but can be set using the
* NMS environment variable. * NMS environment variable.
*/ */
int nms; long int nms;
char * nmsstring = getenv("NMS"); char * nmsstring = getenv("NMS");
nms = nmsstring==NULL ? 100 : atoi(nmsstring); nms = nmsstring==NULL ? 100 : (strtol(nmsstring,NULL,10));
Printf("Speed tests for %d milliseconds\n",nms); Printf("Speed tests for %ld milliseconds\n",nms);
fflush(stdout); fflush(stdout);
/* /*
...@@ -406,7 +406,7 @@ void version(struct stardata_t * RESTRICT const stardata) ...@@ -406,7 +406,7 @@ void version(struct stardata_t * RESTRICT const stardata)
ticks t1 = getticks(); \ ticks t1 = getticks(); \
if(t1!=0) \ if(t1!=0) \
{ \ { \
t1 += nms * millisecond; \ t1 += (ticks)(nms * millisecond); \
while(getticks()<t1) \ while(getticks()<t1) \
{ \ { \
{ \ { \
...@@ -1867,5 +1867,5 @@ void version(struct stardata_t * RESTRICT const stardata) ...@@ -1867,5 +1867,5 @@ void version(struct stardata_t * RESTRICT const stardata)
static float __test_seconds(void) static float __test_seconds(void)
{ {
char * t = getenv("BINARY_C_SPEEDTEST_SECONDS"); char * t = getenv("BINARY_C_SPEEDTEST_SECONDS");
return t == NULL ? 1 : atof(t); return t == NULL ? 1 : strtod(t,NULL);
} }
...@@ -15,6 +15,6 @@ void string_array_to_double_array(char ** RESTRICT const strings, ...@@ -15,6 +15,6 @@ void string_array_to_double_array(char ** RESTRICT const strings,
size_t i; size_t i;
for(i=0;i<n;i++) for(i=0;i<n;i++)
{ {
(*doubles)[i] = atof(strings[i]); (*doubles)[i] = strtod(strings[i],NULL);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment