Skip to content

Commit

Permalink
Merging develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightly Bot authored and cwsmith committed May 11, 2024
2 parents 88892c5 + 2dfed84 commit 1ab42dd
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
32 changes: 16 additions & 16 deletions pcu/pcu_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ void PCU_Assert_Fail(const char* msg) __attribute__ ((noreturn));
} /* extern "C" */
#endif

#define PCU_ALWAYS_ASSERT(cond) \
do { \
if (! (cond)) { \
char omsg[2048]; \
sprintf(omsg, "%s failed at %s + %d \n", \
#cond, __FILE__, __LINE__); \
PCU_Assert_Fail(omsg); \
} \
#define PCU_ALWAYS_ASSERT(cond) \
do { \
if (! (cond)) { \
char omsg[2048]; \
snprintf(omsg, 2048, "%s failed at %s + %d \n", \
#cond, __FILE__, __LINE__); \
PCU_Assert_Fail(omsg); \
} \
} while (0)

#define PCU_ALWAYS_ASSERT_VERBOSE(cond, msg) \
do { \
if (! (cond)) { \
char omsg[2048]; \
sprintf(omsg, "%s failed at %s + %d \n %s", \
#cond, __FILE__, __LINE__, msg); \
PCU_Assert_Fail(omsg); \
} \
#define PCU_ALWAYS_ASSERT_VERBOSE(cond, msg) \
do { \
if (! (cond)) { \
char omsg[2048]; \
snprintf(omsg, 2048, "%s failed at %s + %d \n %s", \
#cond, __FILE__, __LINE__, msg); \
PCU_Assert_Fail(omsg); \
} \
} while(0)

#ifdef NDEBUG
Expand Down
2 changes: 1 addition & 1 deletion phasta/phBubble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void readBubbles(Bubbles& bubbles, std::string bubbleFileName)
FILE *filebubble;
Bubble readbubble;

sprintf(bubblefname, "%s", bubbleFileName.c_str());
snprintf(bubblefname, 1024, "%s", bubbleFileName.c_str());
if (!PCU_Comm_Self())
lion_oprint(1,"reading bubbles info from %s\n",bubblefname);

Expand Down
2 changes: 1 addition & 1 deletion phasta/phiotimer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void phastaio_addWriteTime(size_t t) {
}

void phastaio_setfile(int f) {
char msg[64]; sprintf(msg, "f %d", f);
char msg[64]; snprintf(msg, 64, "f %d", f);
PCU_ALWAYS_ASSERT_VERBOSE(f >= 0 && f < NUM_PHASTAIO_MODES, msg);
phastaio_global_stats.fileIdx = f;
}
Expand Down
2 changes: 1 addition & 1 deletion pumi-meshes
10 changes: 5 additions & 5 deletions test/matchedNodeElmReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void readMesh(const char* meshfilename,
int self = PCU_Comm_Self();

char filename[1024];
sprintf(filename, "%s.%d",coordfilename,self);
snprintf(filename, 1024, "%s.%d",coordfilename,self);

FILE* fc = fopen(filename , "r");
PCU_ALWAYS_ASSERT(fc);
Expand All @@ -689,30 +689,30 @@ void readMesh(const char* meshfilename,
fclose(fc);

if(0==1) {
sprintf(filename, "%s.%d",solutionfilename,self);
snprintf(filename, 1024, "%s.%d",solutionfilename,self);
FILE* fs = fopen(filename, "r");
PCU_ALWAYS_ASSERT(fs);
readSolution(fs, mesh.localNumVerts, &(mesh.solution));
fclose(fs);
}

sprintf(filename, "%s.%d",classfilename,self);
snprintf(filename, 1024, "%s.%d",classfilename,self);
FILE* ff = fopen(filename, "r");
PCU_ALWAYS_ASSERT(ff);
readClassification(ff, mesh.localNumVerts, &(mesh.classification));
fclose(ff);

if( strcmp(fathers2Dfilename, "NULL") ) {
//add an argument to readMesh for the fathers2D
sprintf(filename, "%s.%d",fathers2Dfilename,self);
snprintf(filename, 1024, "%s.%d",fathers2Dfilename,self);
FILE* fff = fopen(filename, "r");
PCU_ALWAYS_ASSERT(fff);
readFathers(fff, mesh.localNumVerts, &(mesh.fathers2D));
fclose(fff);
}

if( strcmp(matchfilename, "NULL") ) {
sprintf(filename, "%s.%d",matchfilename,self);
snprintf(filename, 1024, "%s.%d",matchfilename,self);
FILE* fm = fopen(filename, "r");
PCU_ALWAYS_ASSERT(fm);
readMatches(fm, mesh.numVerts, mesh.localNumVerts, &(mesh.matches));
Expand Down
4 changes: 2 additions & 2 deletions test/measureAnisoStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ void getStats(
char message[512];
// first find the sizes field
sizes = m->findField(sizeName);
sprintf(message, "Couldn't find a field with name %s in mesh!", sizeName);
snprintf(message, 512, "Couldn't find a field with name %s in mesh!", sizeName);
PCU_ALWAYS_ASSERT_VERBOSE(sizes, message);

// then find the frames field if they exist
frames = m->findField(frameName);
sprintf(message, "Couldn't find a field with name %s in mesh!", frameName);
snprintf(message, 512, "Couldn't find a field with name %s in mesh!", frameName);
PCU_ALWAYS_ASSERT_VERBOSE(frames, message);
}

Expand Down
2 changes: 1 addition & 1 deletion test/measureIsoStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void getStats(
char message[512];
// first find the sizes field
sizes = m->findField(sizeName);
sprintf(message, "Couldn't find a field with name %s in mesh!", sizeName);
snprintf(message, 512, "Couldn't find a field with name %s in mesh!", sizeName);
PCU_ALWAYS_ASSERT_VERBOSE(sizes, message);
}

Expand Down
2 changes: 1 addition & 1 deletion test/print_pumipic_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int main(int argc, char** argv)

//Write the partition out
char filename[256];
sprintf(filename , "%s_%d.ptn", argv[4], num_ranks);
snprintf(filename , 256, "%s_%d.ptn", argv[4], num_ranks);
printf("Writing partition to %s\n", filename);
std::ofstream out(filename);
apf::MeshIterator* mitr = m->begin(m->getDimension());
Expand Down
4 changes: 2 additions & 2 deletions test/visualizeAnisoSizes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ void visualizeSizeField(
char message[512];
// first find the sizes field
sizes = m->findField(sizeName);
sprintf(message, "Couldn't find a field with name %s in mesh!", sizeName);
snprintf(message, 512, "Couldn't find a field with name %s in mesh!", sizeName);
PCU_ALWAYS_ASSERT_VERBOSE(sizes, message);

// then find the frames field if they exist
frames = m->findField(frameName);
sprintf(message, "Couldn't find a field with name %s in mesh!", frameName);
snprintf(message, 512, "Couldn't find a field with name %s in mesh!", frameName);
PCU_ALWAYS_ASSERT_VERBOSE(frames, message);
}

Expand Down

0 comments on commit 1ab42dd

Please sign in to comment.