diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 06eadc7..cf15411 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,6 +11,10 @@ jobs: name: GCC DP 2D Profiling runs-on: ubuntu-20.04 if: github.event.pull_request.draft == false + env: + # FIXME: -Wstringop-overflow + # https://github.com/AMReX-Codes/amrex/pull/2660 + CXXFLAGS: "-Werror -Wno-error=stringop-overflow" steps: - uses: actions/checkout@v3 - uses: actions/checkout@v3 @@ -26,4 +30,5 @@ jobs: run: | make -j 2 \ AMREX_HOME=./amrex \ - USE_PROFPARSER=TRUE + USE_PROFPARSER=TRUE \ + EXTRACXXFLAGS="${CXXFLAGS}" diff --git a/Dataset.cpp b/Dataset.cpp index b406325..b67122d 100644 --- a/Dataset.cpp +++ b/Dataset.cpp @@ -29,6 +29,7 @@ const int MAXINDEXCHARS = 4; #include #include +#include #include #include using std::ostringstream; @@ -420,7 +421,7 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, largestWidth = std::max(8, largestWidth); // for no data string } - char levelInfo[Amrvis::LINELENGTH], maxInfo[Amrvis::LINELENGTH], minInfo[Amrvis::LINELENGTH]; + char levelInfo[Amrvis::LINELENGTH]; char maxInfoV[Amrvis::LINELENGTH], minInfoV[Amrvis::LINELENGTH]; sprintf(levelInfo, "Level: %i", maxDrawnLevel); @@ -431,14 +432,16 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, XmStringFree(sNewLevel); sprintf(minInfoV, fstring, rMin); - sprintf(minInfo, "Min:%s", minInfoV); - XmString sNewMin = XmStringCreateSimple(minInfo); + std::string minInfo("Min:"); + minInfo.append(minInfoV); + XmString sNewMin = XmStringCreateSimple(&minInfo[0]); XtVaSetValues(wMinValue, XmNlabelString, sNewMin, NULL); XmStringFree(sNewMin); sprintf(maxInfoV, fstring, rMax); - sprintf(maxInfo, "Max:%s", maxInfoV); - XmString sNewMax = XmStringCreateSimple(maxInfo); + std::string maxInfo("Max:"); + maxInfo.append(maxInfoV); + XmString sNewMax = XmStringCreateSimple(&maxInfo[0]); XtVaSetValues(wMaxValue, XmNlabelString, sNewMax, NULL); XmStringFree(sNewMax); diff --git a/PltApp.cpp b/PltApp.cpp index 1b1cd4b..51a8b26 100644 --- a/PltApp.cpp +++ b/PltApp.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include using std::cout; @@ -2815,7 +2816,6 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { return; } - char range[Amrvis::LINELENGTH]; char saveRangeString[Amrvis::LINELENGTH]; char format[Amrvis::LINELENGTH]; char fMin[Amrvis::LINELENGTH]; @@ -2832,8 +2832,9 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { rtMin, rtMax); sprintf(fMin, format, rtMin); sprintf(fMax, format, rtMax); - sprintf(range, "Min: %s Max: %s", fMin, fMax); - strcpy(saveRangeString, range); + std::string range("Min: "); + range.append(fMin).append(" Max: ").append(fMax); + strcpy(saveRangeString, range.c_str()); XtVaGetValues(wAmrVisTopLevel, XmNx, &xpos, @@ -2964,21 +2965,25 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { pltAppState->CurrentDerivedNumber(), rtMin, rtMax); sprintf(fMin, format, rtMin); sprintf(fMax, format, rtMax); - sprintf(range, "Min: %s", fMin); - XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL); + range = "Min: "; + range.append(fMin); + XtVaCreateManagedWidget(range.c_str(), xmLabelGadgetClass, wRangeRC, NULL); //XtVaSetValues(wid, XmNleftOffset, 20, NULL); - sprintf(range, "Max: %s", fMax); - XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL); + range = "Max: "; + range.append(fMax); + XtVaCreateManagedWidget(range.c_str(), xmLabelGadgetClass, wRangeRC, NULL); pltAppState->GetMinMax(Amrvis::SUBREGIONMINMAX, currentFrame, pltAppState->CurrentDerivedNumber(), rtMin, rtMax); sprintf(fMin, format, rtMin); sprintf(fMax, format, rtMax); - sprintf(range, "Min: %s", fMin); - XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL); - sprintf(range, "Max: %s", fMax); - XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL); + range = "Min: "; + range.append(fMin); + XtVaCreateManagedWidget(range.c_str(), xmLabelGadgetClass, wRangeRC, NULL); + range = "Max: "; + range.append(fMax); + XtVaCreateManagedWidget(range.c_str(), xmLabelGadgetClass, wRangeRC, NULL); pltAppState->GetMinMax(Amrvis::USERMINMAX, currentFrame, pltAppState->CurrentDerivedNumber(), @@ -2990,12 +2995,13 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { NULL); XtVaCreateManagedWidget("Min:", xmLabelGadgetClass, wid, NULL); //XtVaSetValues(wid, XmNmarginWidth, 0, NULL); - sprintf(range, format, rtMin); + char rangec[Amrvis::LINELENGTH]; + sprintf(rangec, format, rtMin); wUserMin = XtVaCreateManagedWidget("local range", xmTextFieldWidgetClass, wid, - XmNvalue, range, + XmNvalue, rangec, XmNeditable, true, - XmNcolumns, strlen(range)+2, + XmNcolumns, strlen(rangec)+2, NULL); AddStaticCallback(wUserMin, XmNactivateCallback, &PltApp::DoUserMin); @@ -3005,12 +3011,12 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) { //XmNborderWidth, 0, NULL); XtVaCreateManagedWidget("Max:", xmLabelGadgetClass, wid, NULL); - sprintf(range, format, rtMax); + sprintf(rangec, format, rtMax); wUserMax = XtVaCreateManagedWidget("local range", xmTextFieldWidgetClass, wid, - XmNvalue, range, + XmNvalue, rangec, XmNeditable, true, - XmNcolumns, strlen(range)+2, + XmNcolumns, strlen(rangec)+2, NULL); AddStaticCallback(wUserMax, XmNactivateCallback, &PltApp::DoUserMax); diff --git a/PltAppOutput.cpp b/PltAppOutput.cpp index 03a6414..f4eb105 100644 --- a/PltAppOutput.cpp +++ b/PltAppOutput.cpp @@ -17,6 +17,8 @@ #include #include +#include + using std::cout; using std::cerr; using std::endl; @@ -61,14 +63,15 @@ void PltApp::DoOutput(Widget w, XtPointer data, XtPointer) { XtSetSensitive(XmSelectionBoxGetChild(wGetFileName, XmDIALOG_HELP_BUTTON), false); - char tempstr[Amrvis::BUFSIZE], tempfilename[Amrvis::BUFSIZE]; + char tempfilename[Amrvis::BUFSIZE]; if(animating2d) { strcpy(tempfilename, AVGlobals::StripSlashes(fileNames[currentFrame]).c_str()); } else { strcpy(tempfilename, AVGlobals::StripSlashes(fileNames[0]).c_str()); } - sprintf(tempstr, "%s_%s", pltAppState->CurrentDerived().c_str(), tempfilename); - XmTextSetString(XmSelectionBoxGetChild(wGetFileName, XmDIALOG_TEXT), tempstr); + std::string tempstr(pltAppState->CurrentDerived().c_str()); + tempstr.append("_").append(tempfilename); + XmTextSetString(XmSelectionBoxGetChild(wGetFileName, XmDIALOG_TEXT), &tempstr[0]); XtManageChild(wGetFileName); XtPopup(XtParent(wGetFileName), XtGrabNone); } // end DoOutput