Skip to content

Commit

Permalink
Make the build stricter and fixed some of the errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Nov 7, 2023
1 parent a9be18c commit f9cdd95
Show file tree
Hide file tree
Showing 40 changed files with 222 additions and 123 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y autoconf gcc g++ git libtool locales make pkg-config && \
locale-gen en_US.UTF-8

ENV CFLAGS='-Wall -Wextra -Werror -Wno-error=deprecated-copy -Wno-error=class-memaccess'
ENV CXXFLAGS='-Wall -Wextra -Werror -Wno-error=deprecated-copy -Wno-error=class-memaccess'
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
apt-get install -y autoconf gcc g++ git libtool locales make pkg-config
- name: Configure Libfpx
env:
CFLAGS: '-Wall -Wextra -Werror -Wno-error=deprecated-copy -Wno-error=class-memaccess'
CXXFLAGS: '-Wall -Wextra -Werror -Wno-error=deprecated-copy -Wno-error=class-memaccess'
run: |
autoreconf -fiv
./configure
Expand Down
12 changes: 12 additions & 0 deletions attributes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifdef __GNUC__ /* Use the -Wno-unused-parameter */
#define UNIMPLEMENTED_PARM(x)
#define UNUSED_PARM(x) magick_unused_ ## x __attribute__((unused))
#define UNREFERENCED_PARM(x)
#define SWITCH_FALLTHROUGH __attribute__ ((fallthrough))
#else
// Use these to 'refer' to the formal parameters that we are not using
#define UNIMPLEMENTED_PARM(x) (x)
#define UNUSED_PARM(x) (x)
#define UNREFERENCED_PARM(x) (x)
#define SWITCH_FALLTHROUGH
#endif
5 changes: 3 additions & 2 deletions basics/a_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#endif

#include "debug.h"

#include <attributes.h>

// Constants
// ---------
Expand Down Expand Up @@ -149,9 +149,10 @@ void Fichier::CloseFileWhenDelete()
}

// Open a file. If file is open to write into, try multiple times on Macintosh.
void Fichier::Ouverture(const FicNom& fNom, mode_Ouverture mode, OSType fileSignature)
void Fichier::Ouverture(const FicNom& fNom, mode_Ouverture mode, OSType UNUSED_PARM(fileSignature))

{
UNREFERENCED_PARM(fileSignature);

#ifdef macintosh
OSErr err = noErr;
Expand Down
26 changes: 18 additions & 8 deletions basics/filename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

#include "b_memory.h"
#include "b_error.h"
#include <attributes.h>


// Constants
Expand Down Expand Up @@ -380,9 +381,12 @@ OSErr FicNom::Exist() const


// File name starting with a period (.) are forbidden (see Inside Macintosh : Files, p.2-173)
OSErr FicNom::CheckNameWithPeriod(Boolean withDialog) const
OSErr FicNom::CheckNameWithPeriod(Boolean UNUSED_PARM(withDialog)) const
{
OSErr err = noErr;

UNREFERENCED_PARM(withDialog);

if (*(nom.Texte()) == '.')
err = badFidErr;
return err;
Expand Down Expand Up @@ -456,9 +460,10 @@ long FicNom::PlaceDisponible() const
}

// Get the size of the file (in KBytes)
OSErr FicNom::GetSize(long* sizeInKBytes)
OSErr FicNom::GetSize(long* UNUSED_PARM(sizeInKBytes))
{

UNREFERENCED_PARM(sizeInKBytes);

#ifdef macintosh
OSErr err = noErr;

Expand Down Expand Up @@ -733,7 +738,7 @@ OSErr FicNom::SearchWithCriteria (FSSpec* tableauDeFSSpec, long* nbReponse, sear

/* Search file routine in a given folder. This routine hides PBGetCatInfoSync() problems*/
/* see Inside Macintosh : Files for PBGetCatInfo documentation */
/* see Lettre des DÄveloppeurs Apple ní23/DÄcembre 1992, p.10 */
/* see Lettre des D�veloppeurs Apple n�23/D�cembre 1992, p.10 */

OSErr FicNom::SearchInFolder (FSSpec* tableauDeFSSpec, long* nbReponse, ptr_FicNom sourceFolder, searchCriteria what, Boolean into)
{
Expand Down Expand Up @@ -1014,10 +1019,12 @@ void FicNom::GetNewLocation()
}
#endif

OSErr FicNom::Copy(const FicNom& newFileName)
OSErr FicNom::Copy(const FicNom& UNUSED_PARM(newFileName))
{
OSErr err;


UNREFERENCED_PARM(newFileName);

#ifdef macintosh
err = FileCopy(this->volume, this->directory, this->nom,
newFileName.volume, newFileName.directory, NULL , newFileName.nom,
Expand All @@ -1031,9 +1038,11 @@ OSErr FicNom::Copy(const FicNom& newFileName)



OSErr FicNom::Rename(const FicNom& newFileName)
OSErr FicNom::Rename(const FicNom& UNUSED_PARM(newFileName))
{
OSErr err;

UNREFERENCED_PARM(newFileName);
#ifdef macintosh
FSSpec mySpec;
CopyToFSSpec (mySpec);
Expand All @@ -1045,9 +1054,10 @@ OSErr FicNom::Rename(const FicNom& newFileName)
return err;
}

OSErr FicNom::Move(const FicNom& newFileName)
OSErr FicNom::Move(const FicNom& UNUSED_PARM(newFileName))
{
OSErr err;
UNIMPLEMENTED_PARM(newFileName);
#ifdef macintosh
if (volume != newFileName.volume)
return (diffVolErr);
Expand Down
3 changes: 3 additions & 0 deletions fpx/coltwist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "fpxlibio.h"
#endif

#include <attributes.h>

// Constants
// ---------

Expand Down Expand Up @@ -491,6 +493,7 @@ Boolean PColorTwist::ApplyToPixelBuffer(Pixel* pixels, FPXBaselineColorSpace col
case SPACE_32_BITS_ARGB: // The 24 bits are stored in the LSB part of the long
case SPACE_32_BITS_AYCC:
alpha_pixel = ((unsigned char*)pixels) + 0;
SWITCH_FALLTHROUGH;
case SPACE_32_BITS_RGB:
case SPACE_32_BITS_YCC:
{
Expand Down
7 changes: 4 additions & 3 deletions fpx/f_fpxio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int ComputeNumberOfResolutions (int width, int height, int tileWidth)
// Methods of the PFileFlashPixIO class
//
// Manage all records to an FPX file. The field "firstSubImage" points to the
// full resolution image which points of the /4 subimage, and so onÐ
// full resolution image which points of the /4 subimage, and so on�
//
// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -178,8 +178,9 @@ PFileFlashPixIO::PFileFlashPixIO (OLEStorage* theOwningStorage, const char* theS
// ----------------------------------------------------------------------------
// Open a file in Read or Write mode (compressed or uncompressed) :
// CAUTION : the file is opened as long as necessary
PFileFlashPixIO::PFileFlashPixIO (FicNom& refName, const char* theStorageName, mode_Ouverture openMode) : PHierarchicalImage (refName)
PFileFlashPixIO::PFileFlashPixIO (FicNom& refName, const char* theStorageName, mode_Ouverture UNUSED_PARM(openMode)) : PHierarchicalImage (refName)
{
UNREFERENCED_PARM(openMode);
Init (); // Init the object
SetTileParameter (FPX_TILE_WIDTH, FPX_TILE_WIDTH);
storageName = theStorageName;
Expand Down Expand Up @@ -267,7 +268,7 @@ PFileFlashPixIO::~PFileFlashPixIO()
{
if (tilesHasBeenModified) {
// CAUTION : delete sub-images before closing file because
// some file's information are used to close sub-imagesÐ
// some file's information are used to close sub-images�
if (firstSubImage)
firstSubImage->CloseSubImage();
// In write mode, we have to commit (write) all changes before deleting anything
Expand Down
5 changes: 4 additions & 1 deletion fpx/f_fpxvw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,11 @@ Boolean PFileFlashPixView::Commit()

#define USERCLASSTYPE_APPNAME 0

HRESULT OleRegGetUserType(REFCLSID clsid, DWORD whatever, LPOLESTR FAR* pszUserType)
HRESULT OleRegGetUserType(REFCLSID UNUSED_PARM(clsid), DWORD UNUSED_PARM(whatever), LPOLESTR FAR* pszUserType)
{
UNIMPLEMENTED_PARM(clsid);
UNIMPLEMENTED_PARM(whatever);

if (*pszUserType == NULL) {
*pszUserType = new OLECHAR[512];
}
Expand Down
10 changes: 7 additions & 3 deletions fpx/fpximgvw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@
// CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView::PFlashPixImageView (FicNom& refName, const char* theStorageName,
long visibleOutputIndex,
FPXStatus * fpxStatus) : ViewImage(refName)
FPXStatus * UNUSED_PARM(fpxStatus)) : ViewImage(refName)

{
CLSID idBaseline = ID_Baseline;
CLSID idImageView = ID_ImageView;
CLSID id;


UNREFERENCED_PARM(fpxStatus);

// Init the file pointers
filePtr = NULL;
image = NULL;
Expand Down Expand Up @@ -441,13 +443,15 @@ PFlashPixImageView::PFlashPixImageView (FicNom& refName, const char* theStorageN
// CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView::PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName,
mode_Ouverture openMode, long visibleOutputIndex,
FPXStatus * fpxStatus ) : ViewImage()
FPXStatus * UNUSED_PARM(fpxStatus) ) : ViewImage()

{
CLSID idBaseline = ID_Baseline;
CLSID idImageView = ID_ImageView;
CLSID id;

UNREFERENCED_PARM(fpxStatus);

internalBuffer = NULL;
internalBufSize = 0;

Expand Down
46 changes: 32 additions & 14 deletions fpx/fpxlibio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,21 +562,27 @@ FPXStatus FPX_SetProgressFunction ( FPXProgressFunction theProgressive)
return FPX_OK;
}

FPXStatus FPX_GetToolkitMemoryLimit ( unsigned long * memoryLimit)
FPXStatus FPX_GetToolkitMemoryLimit ( unsigned long * UNUSED_PARM(memoryLimit))

{
UNREFERENCED_PARM(memoryLimit);

return FPX_NO_MEMORY_MANAGEMENT;
}

FPXStatus FPX_GetToolkitMemoryAvailable ( unsigned long * availableMemory)
FPXStatus FPX_GetToolkitMemoryAvailable ( unsigned long * UNUSED_PARM(availableMemory))

{
UNREFERENCED_PARM(availableMemory);

return FPX_NO_MEMORY_MANAGEMENT;
}

FPXStatus FPX_GetToolkitMemoryUsed ( unsigned long * usedMemory)
FPXStatus FPX_GetToolkitMemoryUsed ( unsigned long * UNUSED_PARM(usedMemory))

{
UNREFERENCED_PARM(usedMemory);

return FPX_NO_MEMORY_MANAGEMENT;
}

Expand Down Expand Up @@ -953,14 +959,16 @@ FPXStatus FPX_ReadImageTransformRectangle (
float X0,
float Y0,
float X1,
float Y1,
float UNUSED_PARM(Y1),
int rectWidth,
int rectHeight,
FPXImageDesc* theRectangle)

{
FPXStatus status = FPX_OK;

UNREFERENCED_PARM(Y1);

if (!theFPX)
status = FPX_INVALID_FPX_HANDLE;
else
Expand Down Expand Up @@ -1192,19 +1200,23 @@ FPXStatus FPX_GetResolutionInfo (

// Not implemented in Baseline
FPXStatus FPX_SetAlphaType (
FPXImageHandle* theFPX,
FPXPreComputedAlpha theAlphaType)
FPXImageHandle* UNUSED_PARM(theFPX),
FPXPreComputedAlpha UNUSED_PARM(theAlphaType))
{
UNREFERENCED_PARM(theFPX);
UNREFERENCED_PARM(theAlphaType);
// FPXImageHandle* handle = theFPX;
// FPXPreComputedAlpha a = theAlphaType;
return FPX_UNIMPLEMENTED_FUNCTION;
}

// Not implemented in Baseline
FPXStatus FPX_GetAlphaType (
FPXImageHandle* theFPX,
FPXPreComputedAlpha* theAlphaType)
FPXImageHandle* UNUSED_PARM(theFPX),
FPXPreComputedAlpha* UNUSED_PARM(theAlphaType))
{
UNREFERENCED_PARM(theFPX);
UNREFERENCED_PARM(theAlphaType);
// FPXImageHandle* handle = theFPX;
// FPXPreComputedAlpha* a = theAlphaType;
return FPX_UNIMPLEMENTED_FUNCTION;
Expand Down Expand Up @@ -2170,21 +2182,27 @@ FPXStatus FPX_GenerateHierarchy (
*/

FPXStatus FPX_SetPath(
FPXImageHandle *theFPX,
unsigned short thePathIndex,
FPXPath* thePath)
FPXImageHandle *UNUSED_PARM(theFPX),
unsigned short UNUSED_PARM(thePathIndex),
FPXPath* UNUSED_PARM(thePath))
{
UNREFERENCED_PARM(theFPX);
UNREFERENCED_PARM(thePathIndex);
UNREFERENCED_PARM(thePath);
// FPXImageHandle *handle = theFPX;
// short p = thePathIndex;
// FPXPath* path= thePath;
return FPX_UNIMPLEMENTED_FUNCTION;
}

FPXStatus FPX_GetPath(
FPXImageHandle *theFPX,
unsigned short thePathIndex,
FPXPath** thePath)
FPXImageHandle *UNUSED_PARM(theFPX),
unsigned short UNUSED_PARM(thePathIndex),
FPXPath** UNUSED_PARM(thePath))
{
UNREFERENCED_PARM(theFPX);
UNREFERENCED_PARM(thePathIndex);
UNREFERENCED_PARM(thePath);
// FPXImageHandle *handle = theFPX;
// short p = thePathIndex;
// FPXPath** path= thePath;
Expand Down
10 changes: 7 additions & 3 deletions fpx/ptil_fpx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ FPXStatus PTileFlashPix::Read()
// now.
if ((pixelsSpace == SPACE_32_BITS_YCC)
|| (pixelsSpace == SPACE_32_BITS_YCCA)
|| (pixelsSpace == SPACE_32_BITS_AYCC))
|| (pixelsSpace == SPACE_32_BITS_AYCC)) {
if (!((used == SPACE_32_BITS_YCC)
|| (used == SPACE_32_BITS_YCCA)
|| (used == SPACE_32_BITS_AYCC))) {
Expand All @@ -1199,9 +1199,10 @@ FPXStatus PTileFlashPix::Read()
pixelsSpace, tmpPixelSpace);
pixelsSpace = tmpPixelSpace;
}
imageParam->GetContrast( &contrastValue);
Contrast( contrastValue, pixelsSpace, pixels, width * height);
}
imageParam->GetContrast( &contrastValue);
Contrast( contrastValue, pixelsSpace, pixels, width * height);
}
}

// Do the color conversion
Expand Down Expand Up @@ -1783,6 +1784,7 @@ FPXStatus PTileFlashPix::Contrast (
switch(pixelsSpace) {
case SPACE_32_BITS_ARGB: // The 24 bits are stored in the LSB part of the long
opac_pixel = ((unsigned char*)pixels);
SWITCH_FALLTHROUGH;
case SPACE_32_BITS_RGB: {
red_pixel = ((unsigned char*)pixels) + 1;
green_pixel = ((unsigned char*)pixels) + 2;
Expand All @@ -1800,6 +1802,7 @@ FPXStatus PTileFlashPix::Contrast (

case SPACE_32_BITS_AM:
opac_pixel = ((unsigned char*)pixels) + 2;
SWITCH_FALLTHROUGH;
case SPACE_32_BITS_M: {
red_pixel = ((unsigned char*)pixels) + 3;
monochrome = true;
Expand All @@ -1813,6 +1816,7 @@ FPXStatus PTileFlashPix::Contrast (

case SPACE_32_BITS_AYCC:
opac_pixel = ((unsigned char*)pixels);
SWITCH_FALLTHROUGH;
case SPACE_32_BITS_YCC: {
tempSpace = SPACE_32_BITS_ARGB;
red_pixel = ((unsigned char*)pixels) + 1;
Expand Down
Loading

0 comments on commit f9cdd95

Please sign in to comment.