View Issue Details

IDProjectCategoryView StatusLast Update
0027463FPCFCLpublic2015-08-30 21:30
Reportersilvioprog Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.1.1 
Target Version3.0.0Fixed in Version3.0.0 
Summary0027463: fcl-web: cosmetic fixes
DescriptionHello,

Please see the attached diff. (generated from the "git format-patch -n HEAD^" command).

Thank you!
TagsNo tags attached.
Fixed in Revision30142
FPCOldBugId
FPCTarget
Attached Files

Activities

silvioprog

2015-02-13 22:25

reporter  

0001-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch (1,595 bytes)   
From c3a204e9199f6abadf0fe53df515d3146311fe9e Mon Sep 17 00:00:00 2001
From: silvioprog <silvioprog@gmail.com>
Date: Fri, 13 Feb 2015 18:15:15 -0300
Subject: [PATCH 1/1] fcl-web: avoids the hints: "Hint: Mixing signed
 expressions and longwords gives a 64bit result", "Hint: Local variable
 "EndRequest" does not seem to be initialized"; "Hint: Local variable "FDS"
 does not seem to be initialized".

---
 packages/fcl-web/src/base/custfcgi.pp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/fcl-web/src/base/custfcgi.pp b/packages/fcl-web/src/base/custfcgi.pp
index 2a8175e..b7bc4dd 100644
--- a/packages/fcl-web/src/base/custfcgi.pp
+++ b/packages/fcl-web/src/base/custfcgi.pp
@@ -309,7 +309,7 @@ var
     else
       begin
 //      Result:=BEtoN(PLongint(@(ARecord^.ContentData[i]))^);
-      Result:=((ARecord^.ContentData[i] and $7f) shl 24) + (ARecord^.ContentData[i+1] shl 16)
+      Result:=Int64(((ARecord^.ContentData[i] and $7f) shl 24)) + (ARecord^.ContentData[i+1] shl 16)
                    + (ARecord^.ContentData[i+2] shl 8) + (ARecord^.ContentData[i+3]);
       inc(i,3);
       end;
@@ -533,6 +533,7 @@ begin
     end;
     Inc(BS,cl);
   Until (BS=L);
+  EndRequest := Default(FCGI_EndRequestRecord);
   FillChar(EndRequest,SizeOf(FCGI_EndRequestRecord),0);
   EndRequest.header.version:=FCGI_VERSION_1;
   EndRequest.header.reqtype:=FCGI_END_REQUEST;
@@ -824,6 +825,7 @@ var
   TimeV: TTimeVal;
 
 begin
+  FDS := Default(TFDSet);
   FD_Zero(FDS);
   FD_Set(FHandle, FDS);
   TimeV.tv_usec := (Timeout mod 1000) * 1000;
-- 
1.9.5.msysgit.0

Marco van de Voort

2015-02-14 12:35

manager   ~0081066

(Probably the relevant contentdata expressions should be cast to cardinal instead of the whole expression to int64)

silvioprog

2015-02-14 17:40

reporter   ~0081070

Oops, please use only the last patch: "0002-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch".

silvioprog

2015-02-14 17:40

reporter  

0002-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch (1,769 bytes)   
From 0f86da1ce8dd803296a8b9b94dd443c07ff1b8fe Mon Sep 17 00:00:00 2001
From: silvioprog <silvioprog@gmail.com>
Date: Sat, 14 Feb 2015 13:36:51 -0300
Subject: [PATCH 1/1] fcl-web: avoids the hints: "Hint: Mixing signed
 expressions and longwords gives a 64bit result", "Hint: Local variable
 "EndRequest" does not seem to be initialized"; "Hint: Local variable "FDS"
 does not seem to be initialized".

---
 packages/fcl-web/src/base/custfcgi.pp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packages/fcl-web/src/base/custfcgi.pp b/packages/fcl-web/src/base/custfcgi.pp
index 2a8175e..b04a933 100644
--- a/packages/fcl-web/src/base/custfcgi.pp
+++ b/packages/fcl-web/src/base/custfcgi.pp
@@ -309,7 +309,7 @@ var
     else
       begin
 //      Result:=BEtoN(PLongint(@(ARecord^.ContentData[i]))^);
-      Result:=((ARecord^.ContentData[i] and $7f) shl 24) + (ARecord^.ContentData[i+1] shl 16)
+      Result:=Int64(((ARecord^.ContentData[i] and $7f) shl 24)) + (ARecord^.ContentData[i+1] shl 16)
                    + (ARecord^.ContentData[i+2] shl 8) + (ARecord^.ContentData[i+3]);
       inc(i,3);
       end;
@@ -533,6 +533,7 @@ begin
     end;
     Inc(BS,cl);
   Until (BS=L);
+  EndRequest := Default(FCGI_EndRequestRecord);
   FillChar(EndRequest,SizeOf(FCGI_EndRequestRecord),0);
   EndRequest.header.version:=FCGI_VERSION_1;
   EndRequest.header.reqtype:=FCGI_END_REQUEST;
@@ -810,6 +811,7 @@ var
   TimeV: TTimeVal;
 
 begin
+  FDS := Default(TFDSet);
   fpFD_Zero(FDS);
   fpFD_Set(FHandle, FDS);
   TimeV.tv_usec := (Timeout mod 1000) * 1000;
@@ -824,6 +826,7 @@ var
   TimeV: TTimeVal;
 
 begin
+  FDS := Default(TFDSet);
   FD_Zero(FDS);
   FD_Set(FHandle, FDS);
   TimeV.tv_usec := (Timeout mod 1000) * 1000;
-- 
1.9.5.msysgit.0

silvioprog

2015-02-14 17:40

reporter   ~0081071

Good. I'll do it ...

silvioprog

2015-02-14 17:42

reporter  

0003-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch (1,769 bytes)   
From 0f86da1ce8dd803296a8b9b94dd443c07ff1b8fe Mon Sep 17 00:00:00 2001
From: silvioprog <silvioprog@gmail.com>
Date: Sat, 14 Feb 2015 13:36:51 -0300
Subject: [PATCH 1/1] fcl-web: avoids the hints: "Hint: Mixing signed
 expressions and longwords gives a 64bit result", "Hint: Local variable
 "EndRequest" does not seem to be initialized"; "Hint: Local variable "FDS"
 does not seem to be initialized".

---
 packages/fcl-web/src/base/custfcgi.pp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packages/fcl-web/src/base/custfcgi.pp b/packages/fcl-web/src/base/custfcgi.pp
index 2a8175e..b04a933 100644
--- a/packages/fcl-web/src/base/custfcgi.pp
+++ b/packages/fcl-web/src/base/custfcgi.pp
@@ -309,7 +309,7 @@ var
     else
       begin
 //      Result:=BEtoN(PLongint(@(ARecord^.ContentData[i]))^);
-      Result:=((ARecord^.ContentData[i] and $7f) shl 24) + (ARecord^.ContentData[i+1] shl 16)
+      Result:=Int64(((ARecord^.ContentData[i] and $7f) shl 24)) + (ARecord^.ContentData[i+1] shl 16)
                    + (ARecord^.ContentData[i+2] shl 8) + (ARecord^.ContentData[i+3]);
       inc(i,3);
       end;
@@ -533,6 +533,7 @@ begin
     end;
     Inc(BS,cl);
   Until (BS=L);
+  EndRequest := Default(FCGI_EndRequestRecord);
   FillChar(EndRequest,SizeOf(FCGI_EndRequestRecord),0);
   EndRequest.header.version:=FCGI_VERSION_1;
   EndRequest.header.reqtype:=FCGI_END_REQUEST;
@@ -810,6 +811,7 @@ var
   TimeV: TTimeVal;
 
 begin
+  FDS := Default(TFDSet);
   fpFD_Zero(FDS);
   fpFD_Set(FHandle, FDS);
   TimeV.tv_usec := (Timeout mod 1000) * 1000;
@@ -824,6 +826,7 @@ var
   TimeV: TTimeVal;
 
 begin
+  FDS := Default(TFDSet);
   FD_Zero(FDS);
   FD_Set(FHandle, FDS);
   TimeV.tv_usec := (Timeout mod 1000) * 1000;
-- 
1.9.5.msysgit.0

silvioprog

2015-02-14 17:43

reporter   ~0081072

Done. Please use only patch 0003. you can delete 0001 and 0002. =)

Michael Van Canneyt

2015-02-16 13:34

administrator   ~0081133

The int64 cast is still there ?

Why did you add Default(TFDSet) ?
That is what fpFD_Zero(FDS); already does ?

silvioprog

2015-02-16 16:39

reporter   ~0081138

Last edited: 2015-02-16 17:08

View 10 revisions

> The int64 cast is still there ?

It is just to eliminate the compiler hints. So it could be:

  function GetVarLength : Integer;
  begin
    if (ARecord^.ContentData[i] and 128) = 0 then
      Result:=ARecord^.ContentData[i]
    else
      begin
//      Result:=BEtoN(PLongint(@(ARecord^.ContentData[i]))^);
      Result:=LongWord(((ARecord^.ContentData[i] and $7f) shl 24)) + (ARecord^.ContentData[i+1] shl 16)
                   + (ARecord^.ContentData[i+2] shl 8) + (ARecord^.ContentData[i+3]);
      inc(i,3);
      end;
    inc(i);
  end;


> Why did you add Default(TFDSet) ?
> That is what fpFD_Zero(FDS); already does ?

The fpFD_Zero function set only the fd_count attribute to 0. The Default command will initialize all the record properties (string to '', integer to 0 etc), avoiding the Hint: Local variable "FDS" does not seem to be initialized messages. So the fpFD_Zero could be changed to Default command (it is very fast too).

So the new changes could be:

function GetVarLength : Integer;
...
      Result:=LongWord(((ARecord^.ContentData[i] and $7f) shl 24)) + (ARecord^.ContentData[i+1] 
shl 16)
                   + (ARecord^.ContentData[i+2] shl 8) + (ARecord^.ContentData[i+3]);
      inc(i,3);
...

...
procedure TFCGIResponse.DoSendContent;
...
  Until (BS=L);
  EndRequest := Default(FCGI_EndRequestRecord);
  FillChar(EndRequest,SizeOf(FCGI_EndRequestRecord),0);
...
end;

...
{$ifdef unix}
function TFCgiHandler.DataAvailable: Boolean;
...
begin
  FDS := Default(TFDSet);
  fpFD_Set(FHandle, FDS);
...
end;
{$else}
function TFCgiHandler.DataAvailable: Boolean;
begin
  FDS := Default(TFDSet);
  FD_Set(FHandle, FDS);
...
end;
{$endif}


Michael Van Canneyt

2015-03-08 11:00

administrator   ~0081720

Applied the patch, thank you very much

silvioprog

2015-03-30 05:19

reporter   ~0082457

Thanks! (y)

Issue History

Date Modified Username Field Change
2015-02-13 22:25 silvioprog New Issue
2015-02-13 22:25 silvioprog File Added: 0001-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch
2015-02-14 12:35 Marco van de Voort Note Added: 0081066
2015-02-14 17:40 silvioprog Note Added: 0081070
2015-02-14 17:40 silvioprog File Added: 0002-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch
2015-02-14 17:40 silvioprog Note Added: 0081071
2015-02-14 17:42 silvioprog File Added: 0003-fcl-web-avoids-the-hints-Hint-Mixing-signed-expressi.patch
2015-02-14 17:43 silvioprog Note Added: 0081072
2015-02-16 09:58 Michael Van Canneyt Assigned To => Michael Van Canneyt
2015-02-16 09:58 Michael Van Canneyt Status new => assigned
2015-02-16 13:34 Michael Van Canneyt Note Added: 0081133
2015-02-16 16:39 silvioprog Note Added: 0081138
2015-02-16 16:40 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:41 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:43 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:44 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:45 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:45 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 16:46 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 17:07 silvioprog Note Edited: 0081138 View Revisions
2015-02-16 17:08 silvioprog Note Edited: 0081138 View Revisions
2015-03-08 11:00 Michael Van Canneyt Fixed in Revision => 30142
2015-03-08 11:00 Michael Van Canneyt Note Added: 0081720
2015-03-08 11:00 Michael Van Canneyt Status assigned => resolved
2015-03-08 11:00 Michael Van Canneyt Fixed in Version => 3.1.1
2015-03-08 11:00 Michael Van Canneyt Resolution open => fixed
2015-03-08 11:00 Michael Van Canneyt Target Version => 3.0.0
2015-03-30 05:19 silvioprog Note Added: 0082457
2015-03-30 05:19 silvioprog Status resolved => closed
2015-08-30 21:30 Joost van der Sluis Fixed in Version 3.1.1 => 3.0.1