Skip to content

Commit c7fad73

Browse files
committed
Merge branch 'code-cleanup' into develop
* code-cleanup: Declare used loop variables in a single line Simplify interface of get_*_info, ... functions Replace calloc with regular c array Remove unecessary comments and todos
2 parents 16a0f2b + 9eb5d49 commit c7fad73

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

compile_info.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,96 +8,96 @@
88

99
#define MAX_INFO_STRING_LENGTH 1024
1010

11-
int get_compiler_info( char **info_str ) {
11+
int get_compiler_info( char *info_str ) {
1212
/* For compiler predfined macros used for identification see
1313
* http://predef.sourceforge.net/precomp.html
1414
*/
1515

1616
/* Cray compiler */
1717
#if defined(_CRAYC)
18-
sprintf( *info_str, "Cray %d.%d", _RELEASE, _RELEASE_MINOR );
18+
sprintf( info_str, "Cray %d.%d", _RELEASE, _RELEASE_MINOR );
1919
#endif
2020

2121
/* GNU compiler */
2222
#if defined(__GNUC__)
2323
# if defined(__GNUC_PATCHLEVEL__)
24-
sprintf( *info_str, "GNU %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ );
24+
sprintf( info_str, "GNU %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ );
2525
# else
26-
sprintf( *info_str, "GNU %d.%d", __GNUC__, __GNUC_MINOR__ );
26+
sprintf( info_str, "GNU %d.%d", __GNUC__, __GNUC_MINOR__ );
2727
# endif
2828

2929
/* Intel compiler */
3030
#elif defined(__INTEL_COMPILER)
3131
int version = (int) __INTEL_COMPILER / 100;
3232
int revision = ((int)__INTEL_COMPILER % 100) / 10;
3333
int patch = (int) __INTEL_COMPILER % 10;
34-
sprintf( *info_str, "Intel %d.%d.%d", version, revision, patch );
34+
sprintf( info_str, "Intel %d.%d.%d", version, revision, patch );
3535

3636
/* PGI compiler */
3737
#elif defined(__PGI)
38-
sprintf( *info_str, "PGI" );
38+
sprintf( info_str, "PGI" );
3939

4040
/* Sun compiler */
4141
#elif defined(__SUNPRO_C)
4242
int version = (__SUNPRO_C >> 12) & 0xf;
4343
int revision_digit1 = (__SUNPRO_C >> 8) & 0xf;
4444
int revision_digit2 = (__SUNPRO_C >> 4) & 0xf;
4545
int patch = (__SUNPRO_C >> 0 ) & 0xf;
46-
sprintf( *info_str, "Sun %d.%d%d.%d", version, revision_digit1, revision_digit2, patch );
46+
sprintf( info_str, "Sun %d.%d%d.%d", version, revision_digit1, revision_digit2, patch );
4747

4848
/* unknown */
4949
#else
50-
sprintf( *info_str, "unknown" );
50+
sprintf( info_str, "unknown" );
5151
#endif
5252

5353
return 0;
5454
}
5555

5656
#if defined(MPI_VERSION)
5757

58-
int get_mpi_info(char **info_str) {
58+
int get_mpi_info(char *info_str) {
5959
#if defined(MVAPICH2)
60-
sprintf(*info_str, "MVAPICH2");
60+
sprintf( info_str, "MVAPICH2");
6161
#elif defined(OPEN_MPI)
62-
sprintf(*info_str, "Open MPI");
62+
sprintf( info_str, "Open MPI");
6363
#elif defined(I_MPI_VERSION)
64-
sprintf(*info_str, "Intel MPI");
64+
sprintf( info_str, "Intel MPI");
6565
#elif defined(CRAY_MPI)
66-
sprintf(*info_str, "Cray MPI");
66+
sprintf( info_str, "Cray MPI");
6767
#elif defined(MPICH)
68-
sprintf(*info_str, "MPICH");
68+
sprintf( info_str, "MPICH");
6969
#else
70-
sprintf(*info_str, "unknown");
70+
sprintf( info_str, "unknown");
7171
#endif
7272
return 0;
7373
}
7474

7575
#endif
7676

7777

78-
int get_compile_time( char **info_str ) {
79-
sprintf( *info_str, "%s %s", __DATE__, __TIME__ );
78+
int get_compile_time( char *info_str ) {
79+
sprintf( info_str, "%s %s", __DATE__, __TIME__ );
8080
return 0;
8181
}
8282

8383

84-
int get_timestamp ( char **info_str ) {
84+
int get_timestamp ( char *info_str ) {
8585
time_t t;
8686
struct tm *ts;
8787
t = time(NULL);
8888
ts = localtime(&t);
89-
sprintf( *info_str, "D%d-%d-%d T%d:%d:%d",
89+
sprintf( info_str, "D%d-%d-%d T%d:%d:%d",
9090
ts->tm_mday, ts->tm_mon + 1, ts->tm_year + 1900,
9191
ts->tm_hour, ts->tm_min, ts->tm_sec );
9292
return 0;
9393
}
9494

9595

96-
int get_host( char **info_str ) {
96+
int get_host( char *info_str ) {
9797
char hostname[1024];
9898
hostname[1023] = '\0';
9999
gethostname(hostname, 1023 );
100-
sprintf( *info_str, "%s", hostname );
100+
sprintf( info_str, "%s", hostname );
101101
return 0;
102102
}
103103

mpi_test_suite.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** \todo CN Maybe redesign the logfile implementation? */
2-
31
#include "config.h"
42

53
#include <stdio.h>
@@ -57,9 +55,6 @@ static int tst_tag_ub = 32767;
5755
/** **/
5856
/****************************************************************************/
5957

60-
/*
61-
* Global functions, which don't fit into another category.
62-
*/
6358
int tst_hash_value (const struct tst_env * env)
6459
{
6560
return (env->comm * 65521 + /* Smallest prime smaller than 2^16 */
@@ -100,10 +95,7 @@ int main (int argc, char * argv[])
10095
}
10196

10297

103-
int i;
104-
int j;
105-
int k;
106-
int l;
98+
int i, j, k, l;
10799
int flag;
108100

109101
int num_comms = 0;
@@ -152,14 +144,14 @@ int main (int argc, char * argv[])
152144

153145
tst_output_init (DEBUG_LOG, TST_OUTPUT_RANK_SELF, TST_REPORT_MAX, TST_OUTPUT_TYPE_LOGFILE, "tst.log");
154146

155-
char *info_str = (char *) calloc(MAX_INFO_STRING_LENGTH, sizeof(char));
156-
get_compiler_info(&info_str);
147+
char info_str[MAX_INFO_STRING_LENGTH];
148+
get_compiler_info(info_str);
157149
tst_output_printf(DEBUG_LOG, TST_REPORT_RUN, "Compiler used was %s\n", info_str);
158-
get_mpi_info(&info_str);
150+
get_mpi_info(info_str);
159151
tst_output_printf(DEBUG_LOG, TST_REPORT_FULL, "MPI version used was %s\n", info_str);
160-
get_compile_time(&info_str);
152+
get_compile_time(info_str);
161153
tst_output_printf(DEBUG_LOG, TST_REPORT_FULL, "Compiled at %s\n", info_str);
162-
get_timestamp(&info_str);
154+
get_timestamp(info_str);
163155
tst_output_printf(DEBUG_LOG, TST_REPORT_FULL, "Started at %s\n", info_str);
164156
#ifndef HAVE_MPI2_THREADS
165157
tst_output_printf(DEBUG_LOG, TST_REPORT_FULL, "Testsuite was compiled without MPI2_THREADS");

0 commit comments

Comments
 (0)