summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-11-03 09:23:10 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-11-03 09:23:10 +0000
commitf56ab00e21d175ef62608342f185c5e7977be078 (patch)
tree1bfc0473e7f51b54d1b276af0efb3ebe41238377
parent52b81606de9ddb65dd608424354a28a856a5daef (diff)
Changing various things pointed to by compiling with -Wall.
Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@1129 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r--src/comm/CactusDefaultComm.c22
-rw-r--r--src/include/ParameterBindings.h6
-rw-r--r--src/include/cctki_Groups.h2
-rw-r--r--src/main/ActiveThorns.c5
-rw-r--r--src/main/Banner.c12
-rw-r--r--src/main/CommandLine.c4
-rw-r--r--src/main/Groups.c2
-rw-r--r--src/main/ProcessCommandLine.c1
-rw-r--r--src/main/ScheduleInterface.c4
-rw-r--r--src/main/WarnLevel.c1
-rw-r--r--src/util/BinaryTree.c18
-rw-r--r--src/util/CactusTimers.c31
-rw-r--r--src/util/Misc.c15
-rw-r--r--src/util/SKBinTree.c6
-rw-r--r--src/util/StoreHandledData.c11
15 files changed, 94 insertions, 46 deletions
diff --git a/src/comm/CactusDefaultComm.c b/src/comm/CactusDefaultComm.c
index 592c9ad8..f01e4af8 100644
--- a/src/comm/CactusDefaultComm.c
+++ b/src/comm/CactusDefaultComm.c
@@ -76,6 +76,12 @@ cGH *CactusDefaultSetupGH(tFleshConfig *config, int convergence_level)
return retval;
}
+ /* Initialise this since it is used later and in exceptional
+ * circumstances might not be initialsed beforehand.
+ */
+
+ variable = -1;
+
/* Create a new Grid Hierarchy */
thisGH = (cGH *)malloc(sizeof(cGH));
@@ -85,14 +91,14 @@ cGH *CactusDefaultSetupGH(tFleshConfig *config, int convergence_level)
/* Need this to be at least one otherwise the memory allocation will fail. */
if(thisGH->cctk_dim == 0) thisGH->cctk_dim = 1;
- thisGH->cctk_iteration = 0;
- thisGH->cctk_gsh = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_lsh = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_lbnd = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_ubnd = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_to = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_from = (int *)malloc(thisGH->cctk_dim*sizeof(int));
- thisGH->cctk_bbox = (int *)malloc(2*thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_iteration = 0;
+ thisGH->cctk_gsh = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_lsh = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_lbnd = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_ubnd = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_to = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_from = (int *)malloc(thisGH->cctk_dim*sizeof(int));
+ thisGH->cctk_bbox = (int *)malloc(2*thisGH->cctk_dim*sizeof(int));
thisGH->cctk_nghostzones = (int *)malloc(2*thisGH->cctk_dim*sizeof(int));
thisGH->cctk_levfac = (int *)malloc(2*thisGH->cctk_dim*sizeof(int));
thisGH->cctk_delta_space = (CCTK_REAL *)malloc(thisGH->cctk_dim*sizeof(CCTK_REAL));
diff --git a/src/include/ParameterBindings.h b/src/include/ParameterBindings.h
index 7e28d40a..d1b590a8 100644
--- a/src/include/ParameterBindings.h
+++ b/src/include/ParameterBindings.h
@@ -26,6 +26,12 @@ int ParameterCreate(const char *name, /* The parameter name */
int n_ranges, /* How many allowed ranges it has */
...);
+int ParameterAddRange(const char *implementation,
+ const char *name,
+ const char *range_origin,
+ const char *range,
+ const char *range_description);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/include/cctki_Groups.h b/src/include/cctki_Groups.h
index 30ff0cab..5fc8c13d 100644
--- a/src/include/cctki_Groups.h
+++ b/src/include/cctki_Groups.h
@@ -17,7 +17,7 @@
extern "C" {
#endif
-int CCTKi_CreateGroup(const char *gname, const char *thorn, const char *imp,
+int CCTK_CreateGroup(const char *gname, const char *thorn, const char *imp,
const char *gtype,
const char *vtype,
const char *gscope,
diff --git a/src/main/ActiveThorns.c b/src/main/ActiveThorns.c
index f887b77a..4356a555 100644
--- a/src/main/ActiveThorns.c
+++ b/src/main/ActiveThorns.c
@@ -413,8 +413,6 @@ int CCTK_IsThornCompiled(const char *name)
int retval;
t_sktree *node;
- struct THORN *thorn;
-
/* Find the thorn */
node = SKTreeFindNode(thornlist, name);
@@ -674,6 +672,9 @@ int CCTK_ImplementationThornList (const char *imp, char ***list, int *n_items)
/* FIXME */
#define _MY_THORN_JUNK_SIZE 10
+
+ retval = 0;
+
/* find all thorns for implementation */
thornlist = (t_sktree*) CCTK_ImpThornList (imp);
diff --git a/src/main/Banner.c b/src/main/Banner.c
index 82da9536..265455a6 100644
--- a/src/main/Banner.c
+++ b/src/main/Banner.c
@@ -17,10 +17,10 @@
#include "cctk_Banner.h"
#include "cctk_FortranString.h"
-static char *rcsis = "$Header$";
+static char *rcsid = "$Header$";
static int number_banners = 0;
-static const char **banner_strings = NULL;
+static char **banner_strings = NULL;
void CCTK_PrintBanners(void);
@@ -81,18 +81,18 @@ void CactusBanner(void)
void CCTK_RegisterBanner(const char *string)
{
const char **temp = NULL;
- const char *newstring;
+ char *newstring;
number_banners++;
/* Resize the array of banner strings */
if (number_banners == 1)
{
- banner_strings = (const char **)malloc( number_banners*sizeof(const char *));
+ banner_strings = (char **)malloc( number_banners*sizeof(char *));
temp = banner_strings;
}
else
{
- temp = realloc( banner_strings, number_banners*sizeof(const char *));
+ temp = (char **)realloc( banner_strings, number_banners*sizeof(char *));
if(temp)
{
@@ -107,7 +107,7 @@ void CCTK_RegisterBanner(const char *string)
/* If this was succesful, copy the data into the array */
if(temp)
{
- newstring = malloc((strlen(string)+1)*sizeof(const char));
+ newstring = (char *)malloc((strlen(string)+1)*sizeof(char));
if(newstring)
{
strcpy(newstring, string);
diff --git a/src/main/CommandLine.c b/src/main/CommandLine.c
index ab048f09..bf93f163 100644
--- a/src/main/CommandLine.c
+++ b/src/main/CommandLine.c
@@ -21,6 +21,7 @@
#include "cctk_Misc.h"
#include "cctk_ActiveThorns.h"
#include "cctk_ParameterFunctions.h"
+#include "cctki_WarnLevel.h"
static char *rcsid = "$Header$";
@@ -57,7 +58,7 @@ void CCTKi_CommandLineTestThornCompiled(const char *optarg)
{
int retval;
- if(retval = CCTK_IsThornCompiled(optarg))
+ if((retval = CCTK_IsThornCompiled(optarg)))
{
printf("Thorn '%s' available.\n", optarg);
}
@@ -133,7 +134,6 @@ void CCTKi_CommandLineDescribeParameter(const char *optarg)
char *thorn;
char *param;
t_param_prop *properties;
- t_range *range;
const char *cthorn;
Util_SplitString(&thorn, &param, optarg, "::");
diff --git a/src/main/Groups.c b/src/main/Groups.c
index acb29791..16dde95b 100644
--- a/src/main/Groups.c
+++ b/src/main/Groups.c
@@ -318,7 +318,7 @@ cGroupDefinition *CCTK_SetupGroup(const char *implementation,
if((group_num = CCTK_GroupIndex(fullname1)) == -1)
{
/* Resize the array of groups */
- if(temp = ((cGroupDefinition *)realloc(groups, (n_groups+1)*sizeof(cGroupDefinition))))
+ if((temp = (cGroupDefinition *)realloc(groups, (n_groups+1)*sizeof(cGroupDefinition))))
{
groups = temp;
diff --git a/src/main/ProcessCommandLine.c b/src/main/ProcessCommandLine.c
index 31b405e7..05f2f9f5 100644
--- a/src/main/ProcessCommandLine.c
+++ b/src/main/ProcessCommandLine.c
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "CommandLine.h"
#include "cctk_Flesh.h"
#include "getopt.h"
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index 4e0ba47a..5319a19a 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -1324,6 +1324,8 @@ static void CCTKi_SchedulePrintTimerInfo(t_TimerInfo *info)
printf("%ld", info->vals[0].val.l);
case val_double:
printf("%g", info->vals[0].val.d);
+ default:
+ printf("Unknown value type at line %d of %s\n", __LINE__, __FILE__);
}
for(i = 1; i < info->n_vals; i++)
@@ -1336,6 +1338,8 @@ static void CCTKi_SchedulePrintTimerInfo(t_TimerInfo *info)
printf("\t%ld", info->vals[i].val.l);
case val_double:
printf("\t%g", info->vals[i].val.d);
+ default:
+ printf("Unknown value type at line %d of %s\n", __LINE__, __FILE__);
}
}
diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c
index 86e51835..fae647ae 100644
--- a/src/main/WarnLevel.c
+++ b/src/main/WarnLevel.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <string.h>
#include "StoreKeyedData.h"
diff --git a/src/util/BinaryTree.c b/src/util/BinaryTree.c
index e57ab153..93464561 100644
--- a/src/util/BinaryTree.c
+++ b/src/util/BinaryTree.c
@@ -199,6 +199,20 @@ void TreePrintNodes(t_tree *root, int depth, void (*print_node)(void *, int))
}
+ /*@@
+ @routine TreeFindNode
+ @date Mon Oct 5 11:06:52 1998
+ @author Tom Goodale
+ @desc
+ Find a node.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
t_tree *TreeFindNode(t_tree *root, void *data, int (*compare)(const void *, const void *))
{
int order;
@@ -219,6 +233,10 @@ t_tree *TreeFindNode(t_tree *root, void *data, int (*compare)(const void *, cons
/* Found it. */
node = root;
}
+ else
+ {
+ node = NULL;
+ }
return node;
}
diff --git a/src/util/CactusTimers.c b/src/util/CactusTimers.c
index c9f00c49..b331df7e 100644
--- a/src/util/CactusTimers.c
+++ b/src/util/CactusTimers.c
@@ -7,7 +7,7 @@
@enddesc
@@*/
-
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -130,6 +130,11 @@ int CCTK_TimerCreate(const char *name)
}
retval = this_timer;
}
+ else
+ {
+ free(timer);
+ retval = -2;
+ }
}
else
{
@@ -183,11 +188,9 @@ int CCTK_TimerCreateI(void)
void CCTK_TimerDestroy(const char *name)
{
t_Timer *timer;
- t_TimerFuncs *funcs;
int this_timer;
- int handle;
- if(this_timer = Util_GetHandle(timers, name, (void **)&timer))
+ if((this_timer = Util_GetHandle(timers, name, (void **)&timer)) > -1)
{
CCTKi_TimerDestroy(this_timer, timer);
}
@@ -211,7 +214,7 @@ void CCTK_TimerDestroyI(int this_timer)
{
t_Timer *timer;
- if(timer = Util_GetHandledData(timers, this_timer))
+ if((timer = Util_GetHandledData(timers, this_timer)) > -1)
{
CCTKi_TimerDestroy(this_timer, timer);
}
@@ -272,7 +275,7 @@ void CCTK_TimerStart(const char *name)
t_Timer *timer;
int this_timer;
- if(this_timer = Util_GetHandle(timers, name, (void **)&timer))
+ if((this_timer = Util_GetHandle(timers, name, (void **)&timer)) > -1)
{
CCTKi_TimerStart(this_timer, timer);
}
@@ -282,7 +285,7 @@ void CCTK_TimerStartI(int this_timer)
{
t_Timer *timer;
- if(timer = Util_GetHandledData(timers, this_timer))
+ if((timer = Util_GetHandledData(timers, this_timer)) > -1)
{
CCTKi_TimerStart(this_timer, timer);
}
@@ -326,7 +329,7 @@ void CCTK_TimerStop(const char *name)
t_Timer *timer;
int this_timer;
- if(this_timer = Util_GetHandle(timers, name, (void **)&timer))
+ if((this_timer = Util_GetHandle(timers, name, (void **)&timer)) > -1)
{
CCTKi_TimerStop(this_timer, timer);
}
@@ -336,7 +339,7 @@ void CCTK_TimerStopI(int this_timer)
{
t_Timer *timer;
- if(timer = Util_GetHandledData(timers, this_timer))
+ if((timer = Util_GetHandledData(timers, this_timer)) > -1)
{
CCTKi_TimerStop(this_timer, timer);
}
@@ -380,7 +383,7 @@ void CCTK_TimerReset(const char *name)
t_Timer *timer;
int this_timer;
- if(this_timer = Util_GetHandle(timers, name, (void **)&timer))
+ if((this_timer = Util_GetHandle(timers, name, (void **)&timer)) > -1)
{
CCTKi_TimerReset(this_timer, timer);
}
@@ -390,7 +393,7 @@ void CCTK_TimerResetI(int this_timer)
{
t_Timer *timer;
- if(timer = Util_GetHandledData(timers, this_timer))
+ if((timer = Util_GetHandledData(timers, this_timer)) > -1)
{
CCTKi_TimerReset(this_timer, timer);
}
@@ -434,7 +437,7 @@ void CCTK_TimerGet(const char *name, t_TimerInfo *info)
t_Timer *timer;
int this_timer;
- if(this_timer = Util_GetHandle(timers, name, (void **)&timer))
+ if((this_timer = Util_GetHandle(timers, name, (void **)&timer)) > -1)
{
CCTKi_TimerGet(this_timer, timer, info);
}
@@ -447,7 +450,7 @@ void CCTK_TimerGetI(int this_timer, t_TimerInfo *info)
{
t_Timer *timer;
- if(timer = Util_GetHandledData(timers, this_timer))
+ if((timer = Util_GetHandledData(timers, this_timer)) > -1)
{
CCTKi_TimerGet(this_timer, timer, info);
}
@@ -466,9 +469,9 @@ static void CCTKi_TimerGet(int this_timer, t_Timer *timer, t_TimerInfo *info)
if(timer)
{
+ total_vars = 0;
if(timer->data)
{
- total_vars = 0;
/* Start the timer info for this timer */
for(handle = 0; handle < n_timertypes; handle++)
{
diff --git a/src/util/Misc.c b/src/util/Misc.c
index 8a8d45dc..791fc44f 100644
--- a/src/util/Misc.c
+++ b/src/util/Misc.c
@@ -28,6 +28,11 @@
#include "cctk_FortranString.h"
#include "cctk_WarnLevel.h"
+int CCTK_RegexMatch(const char *string,
+ const char *pattern,
+ const int nmatch,
+ regmatch_t *pmatch);
+
/*@@
@routine Util_SplitString
@date Wed Jan 20 10:14:00 1999
@@ -75,7 +80,7 @@ int Util_SplitString(char **before, char **after, const char *string, const char
retval = 1;
}
- if(position && before && after)
+ if(position && *before && *after)
{
/* Copy the data */
strncpy(*before, string, (int)(position-string));
@@ -288,9 +293,9 @@ int Util_IntInRange(int inval, const char *range)
* 5 - ) or ]
*/
- if(matched = CCTK_RegexMatch(range,
+ if((matched = CCTK_RegexMatch(range,
"(\\[|\\()?([^]):]*):?([^]):]*)?:?([^]):]*)?(\\]|\\))?",
- 6, pmatch))
+ 6, pmatch)) != 0)
{
/* First work out if the range is closed at the lower end. */
if(pmatch[1].rm_so != -1)
@@ -414,9 +419,9 @@ int Util_DoubleInRange(double inval, const char *range)
* 5 - ) or ]
*/
- if(matched = CCTK_RegexMatch(range,
+ if((matched = CCTK_RegexMatch(range,
"(\\[|\\()?([^]):]*):?([^]):]*)?:?([^]):]*)?(\\]|\\))?",
- 6, pmatch))
+ 6, pmatch)) != 0)
{
/* First work out if the range is closed at the lower end. */
if(pmatch[1].rm_so != -1)
diff --git a/src/util/SKBinTree.c b/src/util/SKBinTree.c
index f74f4d9d..a01a1058 100644
--- a/src/util/SKBinTree.c
+++ b/src/util/SKBinTree.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "SKBinTree.h"
@@ -40,7 +41,6 @@ t_sktree *SKTreeStoreData(t_sktree *root, t_sktree *subtree,
{
int order;
t_sktree *newsubtree;
- t_sktree *lastnode, *node;
if(!subtree)
{
@@ -96,7 +96,7 @@ t_sktree *SKTreeStoreData(t_sktree *root, t_sktree *subtree,
{
newsubtree = SKTreeStoreData(subtree, subtree->right, key, data);
}
- else if(order==0)
+ else
{
/* Duplicate key. */
newsubtree = NULL;
@@ -273,7 +273,7 @@ t_sktree *SKTreeFindNode(t_sktree *root, const char *key)
{
node = SKTreeFindNode(root->right, key);
}
- else if(order==0)
+ else
{
/* Found it. */
node = root;
diff --git a/src/util/StoreHandledData.c b/src/util/StoreHandledData.c
index fecc37d8..c3894e37 100644
--- a/src/util/StoreHandledData.c
+++ b/src/util/StoreHandledData.c
@@ -98,7 +98,6 @@ int Util_NewHandle(cHandledData **storage, const char *name, void *data)
/* Record position of first unused array element. */
(*storage)->first_unused = (*storage)->array_size;
-
}
}
else
@@ -124,9 +123,13 @@ int Util_NewHandle(cHandledData **storage, const char *name, void *data)
/* Change pointer to first unused array element. */
(*storage)->first_unused = FindNextUnused(*storage, (*storage)->first_unused);
- };
- };
- };
+ }
+ }
+ }
+ else
+ {
+ return_code = -1;
+ }
return return_code;