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

GRIB: only emit a CPLDebug() instead of a message on stdout when there are trailing bytes (fixes #8574) #8576

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all 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
14 changes: 14 additions & 0 deletions frmts/grib/degrib/degrib/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "metaname.h"

#include "cpl_port.h"
#include "cpl_error.h"

#define SECT0LEN_BYTE 16

Expand Down Expand Up @@ -985,7 +986,9 @@ int GRIB2Inventory (VSILFILE *fp, inventoryType **Inv, uInt4 *LenInv,
* there are multiple grids in the same message. */
wordType word; /* Used to parse the prodType out of Sect 0. */
int ans; /* The return error code of ReadSect0. */
#if 0
char *msg; /* Used to pop messages off the error Stack. */
#endif
int version; /* Which version of GRIB is in this message. */
uChar prodType; /* Which GRIB2 type of product, 0 is meteo, 1 is
* hydro, 2 is land, 3 is space, 10 is oceanographic.
Expand Down Expand Up @@ -1054,6 +1057,7 @@ int GRIB2Inventory (VSILFILE *fp, inventoryType **Inv, uInt4 *LenInv,
return -2;
} else {
/* Handle case where there are trailing bytes. */
#if 0
msg = errSprintf (nullptr);
printf ("Warning: Inside GRIB2Inventory, Message # %d\n",
msgNum);
Expand All @@ -1066,6 +1070,16 @@ int GRIB2Inventory (VSILFILE *fp, inventoryType **Inv, uInt4 *LenInv,
/* fseek (fp, 0L, SEEK_SET); */
printf ("There were " CPL_FRMT_GUIB " trailing bytes in the file.\n",
fileLen - offset);
#endif
#else
#ifdef DEBUG
/* find out how big the file is. */
VSIFSeekL (fp, 0L, SEEK_END);
fileLen = VSIFTellL(fp);
CPLDebug("GRIB", CPL_FRMT_GUIB " trailing byte(s) found after message #%d", fileLen - offset, msgNum);
#else
CPLDebug("GRIB", "Trailing byte(s) found after message #%d", msgNum);
#endif
#endif
free (buffer);
free (buff);
Expand Down