Description: Fix some compiler warnings.
 Also check the return value of fread/fgets.
 .
 comparison of distinct pointer types lacks a cast
 assignment makes integer from pointer without a cast [-Wint-conversion]
 'main' is usually a function [-Wmain]
 'foo' may be used uninitialized in this function
 missing braces around initializer [-Wmissing-braces]
 passing argument N of ‘foo:’ from distinct Objective-C type
 passing argument N of ‘foo:’ from incompatible pointer type
 initialization of ‘double *’ from incompatible pointer type ‘id’
 initialization from distinct Objective-C type
 "GNUSTEP" redefined
Author: Yavor Doganov <yavor@gnu.org>
Forwarded: no
Last-Update: 2025-04-09
---

--- lynkeos.app.orig/application/Sources/FFmpegReader.m
+++ lynkeos.app/application/Sources/FFmpegReader.m
@@ -200,7 +200,7 @@
       return( pix->_frame );
 
    int ret;
-   BOOL success;
+   BOOL success = NO;
 
    // Do not move if the frame already read is asked
    if ( index == (_nextIndex - 1) )
@@ -442,7 +442,7 @@
          _height = (_pCodecCtx->height * aspect.num) / aspect.den;
       }
       const AVPixFmtDescriptor *fmtDesc = av_pix_fmt_desc_get(_pCodecCtx->pix_fmt);
-      if (fmtDesc == nil)
+      if (fmtDesc == NULL)
       {
          NSLog( @"Unknown pixel format" );
          [self release];
--- lynkeos.app.orig/application/Sources/MyImageListWindow.m
+++ lynkeos.app/application/Sources/MyImageListWindow.m
@@ -625,10 +625,11 @@
 
 - (void)windowDidBecomeMain:(NSNotification *)aNotification
 {
-   NSWindow *main = [self window];
+   NSWindow *mainWindow = [self window];
    NSWindow *sender = [aNotification object];
 
-   NSAssert1( sender == main, @"Unexpected window becomes main : %@", sender );
+   NSAssert1( sender == mainWindow,
+              @"Unexpected window becomes main : %@", sender );
 
    if ( _currentProcessDisplay == SeparateView
        || _currentProcessDisplay == SeparateView_NoList )
@@ -644,10 +645,11 @@
 
 - (void)windowDidResignMain:(NSNotification *)aNotification
 {
-   NSWindow *main = [self window];
+   NSWindow *mainWindow = [self window];
    NSWindow *sender = [aNotification object];
 
-   NSAssert1( sender == main, @"Unexpected window becomes main : %@", sender );
+   NSAssert1( sender == mainWindow,
+              @"Unexpected window becomes main : %@", sender );
 
    if ( _currentProcessDisplay == SeparateView
        || _currentProcessDisplay == SeparateView_NoList )
@@ -1470,7 +1472,7 @@
 
 - (void) showHideImageList:(id)sender
 {
-   LynkeosProcessingViewFrame_t display;
+   LynkeosProcessingViewFrame_t display = BottomTab;
 
    switch( _currentProcessDisplay )
    {
@@ -1488,7 +1490,7 @@
 
 - (void) attachDetachProcessView:(id)sender
 {
-   LynkeosProcessingViewFrame_t display;
+   LynkeosProcessingViewFrame_t display = BottomTab;
 
    switch( _currentProcessDisplay )
    {
@@ -1598,7 +1600,7 @@
 
    if (img != nil)
    {
-      NSPoint offsets[3] = {0.0, 0.0, 0.0};
+      NSPoint offsets[3] = {{0.0}, {0.0}, {0.0}};
       LynkeosIntegerRect r = ctrl->cropRectangle;
       u_short x, y, c;
 
--- lynkeos.app.orig/application/Sources/MyProcessingThread.m
+++ lynkeos.app/application/Sources/MyProcessingThread.m
@@ -145,7 +145,7 @@
    NSAutoreleasePool *pool;
    NSPort *rxPort;
    LynkeosThreadConnection *cnx;
-   MyProcessingThread *threadController;
+   MyProcessingThread *threadController = nil;
    MyDocument *doc;
 
    pool = [[NSAutoreleasePool alloc] init];
--- lynkeos.app.orig/application/Sources/MyTiff16Reader.m
+++ lynkeos.app/application/Sources/MyTiff16Reader.m
@@ -280,7 +280,7 @@
 
             for( xs = x; xs < x+w; xs++ )
             {
-               float v;
+               float v = 0;
 
                switch ( _nBits )
                {
--- lynkeos.app.orig/application/Sources/MyTiffWriter.m
+++ lynkeos.app/application/Sources/MyTiffWriter.m
@@ -89,7 +89,7 @@
    void *buf;
    u_short s, x, y, c;
    u_long hstrip;
-   double max;
+   double max = 0;
 
    // Choose a strip size
    hstrip = 256*1024/scanLineW;
--- lynkeos.app.orig/application/GNUstep/GNUmakefile
+++ lynkeos.app/application/GNUstep/GNUmakefile
@@ -103,7 +103,8 @@
 			 -lcfitsio -lpthread $(LIBRAW_LIBS)
 #ADDITIONAL_LIB_DIRS += 
 
-ADDITIONAL_OBJCFLAGS += -std=gnu99 -Wno-unknown-pragmas
+ADDITIONAL_OBJCFLAGS += -std=gnu99 -Wno-unknown-pragmas -Wno-cpp
+ADDITIONAL_CFLAGS += -Wno-cpp
 ADDITIONAL_CPPFLAGS += -I. -I.. -I$(PWD).. -I$(PWD)/../Sources \
 -I$(PWD)/../ThreadConnectionSources \
 -I$(PWD)/../ThirdPartySources/SMDoubleSlider -DNO_FRAMEWORK_CHECK=1
--- lynkeos.app.orig/application/Sources/MyImageStacker.m
+++ lynkeos.app/application/Sources/MyImageStacker.m
@@ -232,7 +232,7 @@
    else
    {
       LynkeosImageBuffer* image = nil;
-      NSPoint offsets[3] = {0.0, 0.0, 0.0};
+      NSPoint offsets[3] = {{0.0}, {0.0}, {0.0}};
       LynkeosIntegerRect r = _params->_cropRectangle;
 
       id <LynkeosAlignResult> alignRes
--- lynkeos.app.orig/application/Sources/LynkeosBasicAlignResult.m
+++ lynkeos.app/application/Sources/LynkeosBasicAlignResult.m
@@ -29,6 +29,10 @@
 #define K_ALIGN_OFFSET        @"offset"
 #define K_ALIGN_TRANSFORM     @"transform"
 
+@interface LynkeosBasicAlignResult(Private)
+- (void) cacheValues;
+@end
+
 @implementation LynkeosBasicAlignResult(Private)
 - (void) cacheValues
 {
--- lynkeos.app.orig/application/Sources/MyImageAlignerView.m
+++ lynkeos.app/application/Sources/MyImageAlignerView.m
@@ -729,7 +729,7 @@
       NSNumberFormatter *xFormat = [[NSNumberFormatter alloc] init];
       [xFormat setFormatterBehavior:NSNumberFormatterBehavior10_4];
       [xFormat setAllowsFloats:NO];
-      [xFormat setMinimum:[NSNumber numberWithInt:0]];
+      [xFormat setMinimum:[NSDecimalNumber zero]];
       [_xField setFormatter:xFormat];
       [_xField setEditable:YES];
 
@@ -737,7 +737,7 @@
       NSNumberFormatter *yFormat = [[NSNumberFormatter alloc] init];
       [yFormat setFormatterBehavior:NSNumberFormatterBehavior10_4];
       [yFormat setAllowsFloats:NO];
-      [yFormat setMinimum:[NSNumber numberWithInt:0]];
+      [yFormat setMinimum:[NSDecimalNumber zero]];
       [_yField setFormatter:yFormat];
       [_yField setEditable:YES];
 
@@ -745,7 +745,8 @@
       NSNumberFormatter *sizeFormat = [[NSNumberFormatter alloc] init];
       [sizeFormat setFormatterBehavior:NSNumberFormatterBehavior10_4];
       [sizeFormat setAllowsFloats:NO];
-      [sizeFormat setMinimum:[NSNumber numberWithInt:2]];
+      [sizeFormat setMinimum:
+                    [[[NSDecimalNumber alloc] initWithInt:2] autorelease]];
       [_sizeField setFormatter:sizeFormat];
       [_sizeField setControlSize:NSControlSizeSmall];
       [_sizeField setEditable:YES];
--- lynkeos.app.orig/application/Sources/MyImageListItem.m
+++ lynkeos.app/application/Sources/MyImageListItem.m
@@ -1085,7 +1085,7 @@
       NSPoint *lOffsets = (NSPoint*)malloc(sizeof(NSPoint)*_nPlanes);
       u_short p;
       for (p = 0; p < _nPlanes; p++)
-         lOffsets[p] = (offsets != nil ? offsets[p] : NSMakePoint(0.0, 0.0));
+         lOffsets[p] = (offsets != NULL ? offsets[p] : NSMakePoint(0.0, 0.0));
 
       if ( _index == NSNotFound )
          // Image file
--- lynkeos.app.orig/application/Sources/FITSReader.m
+++ lynkeos.app/application/Sources/FITSReader.m
@@ -259,7 +259,7 @@
    NSBitmapImageRep* bitmap;
 
    // Create a RGBA bitmap
-   bitmap = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
+   bitmap = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
                                    pixelsWide:_width
                                    pixelsHigh:_height
                                 bitsPerSample:8
--- lynkeos.app.orig/application/Sources/FITSWriter.m
+++ lynkeos.app/application/Sources/FITSWriter.m
@@ -86,7 +86,7 @@
               metaData:(NSDictionary*)metaData
 {
    fitsfile *fits;
-   double *buf = nil;
+   double *buf = NULL;
    u_short x, y;
    double max, offset, scale, datamax, datamin;
    int err = 0;
--- lynkeos.app.orig/application/Sources/DcrawReader.m
+++ lynkeos.app/application/Sources/DcrawReader.m
@@ -248,7 +248,7 @@
 
    while ([infoTask isRunning])
    {
-      if (progressSession != nil)
+      if (progressSession != 0)
          [NSApp runModalSession:progressSession];
       [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
    }
@@ -539,7 +539,7 @@
 
          while ([_dcrawTask isRunning])
          {
-            if (progressSession != nil)
+            if (progressSession != 0)
                [NSApp runModalSession:progressSession];
             [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
          }
@@ -555,22 +555,26 @@
 
          ppmFile = fopen( [_ppmFilePath fileSystemRepresentation], "rb" );
 
-         fgets( line, 40, ppmFile ); // First line of input "P5" or "P6"
-         if ( strcmp( "P5\n", line ) == 0 )
-            NSAssert( _numberOfPlanes == 1,
-                      @"Number of planes inconsistent after conversion" );
-         else if ( strcmp( "P6\n", line ) == 0 )
-            NSAssert( _numberOfPlanes == 3,
-                      @"Number of planes inconsistent after conversion" );
-
-         fgets( line, 40, ppmFile ); // Second line "w h"
-         NSAssert( sscanf( line, "%hu %hu", &w, &h ) == 2,
-                   @"Cannot read image size after conversion" );
-         NSAssert( w == _width && h == _height,
-                   @"Image size inconsistent after conversion" );
-         fgets( line, 40, ppmFile ); // Third line "max"
-         if ( sscanf( line, "%hu", &_dataMax ) != 1 )
-            _dataMax = 0;
+         if ( fgets( line, 40, ppmFile ) ) // First line of input "P5" or "P6"
+           {
+             if ( strcmp( "P5\n", line ) == 0 )
+               NSAssert( _numberOfPlanes == 1,
+                         @"Number of planes inconsistent after conversion" );
+             else if ( strcmp( "P6\n", line ) == 0 )
+               NSAssert( _numberOfPlanes == 3,
+                         @"Number of planes inconsistent after conversion" );
+           }
+
+         if ( fgets( line, 40, ppmFile ) ) // Second line "w h"
+           {
+             NSAssert( sscanf( line, "%hu %hu", &w, &h ) == 2,
+                       @"Cannot read image size after conversion" );
+             NSAssert( w == _width && h == _height,
+                       @"Image size inconsistent after conversion" );
+           }
+         if ( fgets( line, 40, ppmFile ) ) // Third line "max"
+           if ( sscanf( line, "%hu", &_dataMax ) != 1 )
+             _dataMax = 0;
 
          _ppmDataOffset = ftell( ppmFile );
 
@@ -633,7 +637,8 @@
          fseek( ppmFile,
                 _ppmDataOffset + sizeof(u_short)*_numberOfPlanes*((y+ys)*_width+x),
                 SEEK_SET );
-         fread( &data[ys*w*_numberOfPlanes], _numberOfPlanes*sizeof(u_short), w, ppmFile );
+         if ( fread( &data[ys*w*_numberOfPlanes], _numberOfPlanes*sizeof(u_short), w, ppmFile ) == 0 )
+           break;
       }
 
       fclose( ppmFile );
--- lynkeos.app.orig/application/ThirdPartySources/SMDoubleSlider/SMDoubleSliderCell.m
+++ lynkeos.app/application/ThirdPartySources/SMDoubleSlider/SMDoubleSliderCell.m
@@ -19,7 +19,6 @@
 #import "SMDoubleSliderCell.h"
 #import "SMDoubleSlider.h"
 
-#define GNUSTEP
 
 @interface SMDoubleSliderCell(_sm_Private)
 	// A private method to calculate the rectangle of the low knob.
--- lynkeos.app.orig/application/Sources/MyGeneralPrefs.m
+++ lynkeos.app/application/Sources/MyGeneralPrefs.m
@@ -82,7 +82,7 @@
                  includingPropertiesForKeys:
                     [NSArray arrayWithObject:NSURLTypeIdentifierKey]
                                     options:0
-                               errorHandler:nil];
+                               errorHandler:NULL];
 
       if(bundleEnum)
       {
--- lynkeos.app.orig/application/Sources/LynkeosFourierBuffer.m
+++ lynkeos.app/application/Sources/LynkeosFourierBuffer.m
@@ -118,7 +118,7 @@
                                        inDomain:NSUserDomainMask
                               appropriateForURL:nil
                                          create:YES
-                                          error:nil];
+                                          error:NULL];
    if (supportDir != nil)
    {
       wisdomFile = [supportDir URLByAppendingPathComponent:
@@ -422,20 +422,20 @@
 #endif
 
 static const ArithmeticOperation_t Mul_Spectrum
-   = {.stdProcessOneLine  = std_spectrum_mul_one_line,
-      .vectProcessOneLine = vect_spectrum_mul_one_line,
+   = {.stdProcessOneLine  = (ImageProcessOneLine_t)std_spectrum_mul_one_line,
+      .vectProcessOneLine = (ImageProcessOneLine_t)vect_spectrum_mul_one_line,
       .scalar            = NO};
 static const ArithmeticOperation_t Div_Spectrum
-   = {.stdProcessOneLine  = std_spectrum_div_one_line,
-      .vectProcessOneLine = vect_spectrum_div_one_line,
+   = {.stdProcessOneLine  = (ImageProcessOneLine_t)std_spectrum_div_one_line,
+      .vectProcessOneLine = (ImageProcessOneLine_t)vect_spectrum_div_one_line,
       .scalar            = NO};
 static const ArithmeticOperation_t MulConjugate_Spectrum
-   = {.stdProcessOneLine  = std_spectrum_mul_conjugate_one_line,
-      .vectProcessOneLine = vect_spectrum_mul_conjugate_one_line,
+   = {.stdProcessOneLine  = (ImageProcessOneLine_t)std_spectrum_mul_conjugate_one_line,
+      .vectProcessOneLine = (ImageProcessOneLine_t)vect_spectrum_mul_conjugate_one_line,
       .scalar            = NO};
 static const ArithmeticOperation_t Scale_Spectrum
-   = {.stdProcessOneLine  = std_spectrum_scale_one_line,
-      .vectProcessOneLine = vect_spectrum_scale_one_line,
+   = {.stdProcessOneLine  = (ImageProcessOneLine_t)std_spectrum_scale_one_line,
+      .vectProcessOneLine = (ImageProcessOneLine_t)vect_spectrum_scale_one_line,
       .scalar            = YES};
 
 @implementation LynkeosFourierBuffer
