Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC 10.3: Wformat-overflow #17

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
name: GCC DP 2D Profiling
runs-on: ubuntu-20.04
if: github.event.pull_request.draft == false
env:
CXXFLAGS: "-Werror"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
Expand All @@ -26,4 +28,5 @@ jobs:
run: |
make -j 2 \
AMREX_HOME=./amrex \
USE_PROFPARSER=TRUE
USE_PROFPARSER=TRUE \
EXTRACXXFLAGS="${CXXFLAGS}"
13 changes: 8 additions & 5 deletions Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const int MAXINDEXCHARS = 4;
#include <AMReX_DataServices.H>

#include <sstream>
#include <string>
#include <cfloat>
#include <cmath>
using std::ostringstream;
Expand Down Expand Up @@ -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);

Expand All @@ -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:");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change this for compatibility, but we could add a space here:

Suggested change
std::string minInfo("Min:");
std::string minInfo("Min: ");

minInfo.append(minInfoV);
XmString sNewMin = XmStringCreateSimple(minInfo.c_str());
ax3l marked this conversation as resolved.
Show resolved Hide resolved
XtVaSetValues(wMinValue, XmNlabelString, sNewMin, NULL);
XmStringFree(sNewMin);

sprintf(maxInfoV, fstring, rMax);
sprintf(maxInfo, "Max:%s", maxInfoV);
XmString sNewMax = XmStringCreateSimple(maxInfo);
std::string maxInfo("Max:");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change this for compatibility, but we could add a space here:

Suggested change
std::string maxInfo("Max:");
std::string maxInfo("Max: ");

maxInfo.append(maxInfoV);
XmString sNewMax = XmStringCreateSimple(maxInfo.c_str());
ax3l marked this conversation as resolved.
Show resolved Hide resolved
XtVaSetValues(wMaxValue, XmNlabelString, sNewMax, NULL);
XmStringFree(sNewMax);

Expand Down
27 changes: 16 additions & 11 deletions PltApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include <cctype>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdlib>
using std::cout;
Expand Down Expand Up @@ -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];
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down