From: beware <beware@bircd.org>
Date: Mon, 21 Feb 2011 21:40:05 +0000 (+0000)
Subject: eliminated a lot of hints and warnings
X-Git-Url: http://www.lcore.org/git/lcore.git/commitdiff_plain/27e903c56380abcb11b5a0b8d7ccab88a14b5cde?ds=sidebyside;hp=a83971b64b0b20f6774cf3ccedd05202ad0bdb0e

eliminated a lot of hints and warnings

git-svn-id: file:///svnroot/lcore/trunk@94 b1de8a11-f9be-4011-bde0-cc7ace90066a
---

diff --git a/bfifo.pas b/bfifo.pas
index 55cc24a..667c0da 100644
--- a/bfifo.pas
+++ b/bfifo.pas
@@ -76,7 +76,6 @@ end;
 function tfifo.get;
 var
   p:tlinklist;
-  a:integer;
 begin
   if len > size then len := size;
   if len <= 0 then begin
diff --git a/binipstuff.pas b/binipstuff.pas
index 1f5fed4..1cfa34d 100644
--- a/binipstuff.pas
+++ b/binipstuff.pas
@@ -4,6 +4,10 @@
   ----------------------------------------------------------------------------- }
 unit binipstuff;
 
+{$ifdef fpc}
+{$mode delphi}
+{$endif}
+
 interface
 
 {$include lcoreconfig.inc}
@@ -14,9 +18,6 @@ uses
 {$endif}
   pgtypes;
 
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
 {$ifdef cpu386}{$define i386}{$endif}
 {$ifdef i386}{$define ENDIAN_LITTLE}{$endif}
 
diff --git a/btime.pas b/btime.pas
index 62b957d..c130144 100644
--- a/btime.pas
+++ b/btime.pas
@@ -226,7 +226,7 @@ var
   f,g:float;
   o:tosversioninfo;
   isnt:boolean;
-  is9x:boolean;
+{  is9x:boolean;}
 begin
   if (performancecountfreq = 0) then qpctimefloat;
   ticks_freq_known := false;
@@ -239,7 +239,7 @@ begin
   o.dwOSVersionInfoSize := sizeof(o);
   getversionex(o);
   isnt := o.dwPlatformId = VER_PLATFORM_WIN32_NT;
-  is9x := o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
+{  is9x := o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;}
 
   ticks_freq2 := f;
   mmtime_synchedqpc := false;
@@ -327,14 +327,14 @@ const
   maxretries=5;
   margin=0.002;
 var
-  jump:float;
-  mm,f,qpc,newdrift,f1,f2:float;
+{  jump:float;}
+  mm,f,qpc,newdrift:float;
   qpcjumped:boolean;
-  a,b,c:integer;
-  retrycount:integer;
+  a,b:integer;
+{  retrycount:integer;}
 begin
   if not ticks_freq_known then measure_ticks_freq;
-  retrycount := maxretries;
+{  retrycount := maxretries;}
 
   qpc := qpctimefloat;
   mm := mmtimefloat;
@@ -351,7 +351,7 @@ begin
       mmtime_prev_lastsyncqpc := mmtime_lastsyncqpc;
 
       mm := mmtimefloat;
-      dec(retrycount);
+    {  dec(retrycount);}
       settc;
       result := qpctimefloat;
       f := mmtimefloat;
@@ -382,6 +382,7 @@ begin
 {          mmtime_drift := mmtime_drift + mmtime_driftavg[a];}
         end;
 {        mmtime_drift := mmtime_drift / b;}
+        a := 5;
         if (b = 1) then a := 5 else if (b = 2) then a := 15 else if (b = 3) then a := 30 else if (b = 4) then a := 60 else if (b = 5) then a := 120 else if (b >= 5) then a := 120;
         mmtime_nextdriftcorrection := qpc + a;
         if (b >= 2) then warmup_finished := true;
@@ -399,10 +400,10 @@ begin
     qpc := qpctimefloat;
 
     result := (qpc - mmtime_lastsyncqpc) * mmtime_drift + mmtime_lastsyncmm;
-    f := (qpc - mmtime_prev_lastsyncqpc) * mmtime_prev_drift + mmtime_prev_lastsyncmm;
 
+    {f := (qpc - mmtime_prev_lastsyncqpc) * mmtime_prev_drift + mmtime_prev_lastsyncmm;
     jump := result-f;
-    {writeln('jump ',formatfloat('0.000000',jump),'   drift ',formatfloat('0.00000000',mmtime_drift),' duration ',formatfloat('0.000',(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)),' ',formatfloat('0.00000000',jump/(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)));}
+    writeln('jump ',formatfloat('0.000000',jump),'   drift ',formatfloat('0.00000000',mmtime_drift),' duration ',formatfloat('0.000',(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)),' ',formatfloat('0.00000000',jump/(mmtime_lastsyncqpc-mmtime_prev_lastsyncqpc)));}
 
     f := result;
   end;
diff --git a/dnssync.pas b/dnssync.pas
index 7d6631c..c603b92 100644
--- a/dnssync.pas
+++ b/dnssync.pas
@@ -75,14 +75,14 @@ implementation
 
 {$i unixstuff.inc}
 
+
+{$ifdef syncdnscore}
 var
   numsockused:integer;
   fd:array[0..numsock-1] of integer;
   state:array[0..numsock-1] of tdnsstate;
   toaddr:array[0..numsock-1] of tbinip;
 
-{$ifdef syncdnscore}
-
 {$ifdef win32}
   const
     winsocket = 'wsock32.dll';
@@ -109,7 +109,6 @@ end;
 
 function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean;
 var
-  a:integer;
   addr       : ansistring;
   port       : ansistring;
   inaddr     : TInetSockAddrV;
@@ -177,7 +176,6 @@ var
   currenttime  : integer;
 
   lag            : ttimeval;
-  currenttimeout : ttimeval;
   selecttimeout	 : ttimeval;
   socknum:integer;
   needprocessing:array[0..numsock-1] of boolean;
@@ -299,7 +297,7 @@ end;
 function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist;
 var
   dummy : integer;
-  a,b:integer;
+  a:integer;
   biniptemp:tbinip;
   l:tbiniplist;
 begin
diff --git a/dnswin.pas b/dnswin.pas
index 847f0fd..567ea68 100644
--- a/dnswin.pas
+++ b/dnswin.pas
@@ -21,7 +21,6 @@ type
   tdnswinasync=class(tthread)
   private
     freverse : boolean;
-    error : integer;
     freewhendone : boolean;
     hadevent : boolean;
   protected
@@ -88,6 +87,7 @@ var
   hostent : phostent;
   addrlist:^pointer;
 begin
+  output := nil;
   if hints.ai_family <> af_inet6 then begin
     result := 0;
 
@@ -264,6 +264,7 @@ begin
     if assigned (dwas.onrequestdone) then dwas.onrequestdone(dwas,awparam);
     dwas.hadevent := true;
     if dwas.freewhendone then dwas.free;
+    result := 0; {added returning 0 when handling --beware}
   end else begin
     //not passing unknown messages on to defwindowproc will cause window
     //creation to fail! --plugwash
diff --git a/lcore.pas b/lcore.pas
index 0f6eaef..1a2f93c 100755
--- a/lcore.pas
+++ b/lcore.pas
@@ -258,18 +258,20 @@ implementation
 
 {!!! added sleep call -beware}
 procedure sleep(i:integer);
+{$ifdef win32}
+begin
+  windows.sleep(i);
+{$else}
 var
   tv:ttimeval;
 begin
-  {$ifdef win32}
-    windows.sleep(i);
-  {$else}
-    tv.tv_sec := i div 1000;
-    tv.tv_usec := (i mod 1000) * 1000;
-    select(0,nil,nil,nil,@tv);
-  {$endif}
+  tv.tv_sec := i div 1000;
+  tv.tv_usec := (i mod 1000) * 1000;
+  select(0,nil,nil,nil,@tv);
+{$endif}
 end;
 
+
 destructor tlcomponent.destroy;
 begin
   disconnecttasks(self);
diff --git a/lcoreselect.pas b/lcoreselect.pas
index 659bfce..38da6ba 100755
--- a/lcoreselect.pas
+++ b/lcoreselect.pas
@@ -64,7 +64,7 @@ type
 
 procedure processtimers;inline;
 var
-  tv           ,tvnow     : ttimeval ;
+  tvnow     : ttimeval ;
   currenttimer            : tltimer   ;
   temptimer               : tltimer  ;
 
@@ -90,7 +90,6 @@ end;
 procedure processasios(var fdsr,fdsw:fdset);//inline;
 var
   currentsocket : tlasio  ;
-  tempsocket    : tlasio  ;
   socketcount   : integer ; // for debugging perposes :)
   dw,bt:integer;
   currentfdword:fdword;
diff --git a/lsocket.pas b/lsocket.pas
index bcff643..642ec9a 100755
--- a/lsocket.pas
+++ b/lsocket.pas
@@ -134,6 +134,15 @@ type
 
       //this one has to be kept public for now because lcorewsaasyncselect calls it
       procedure connectionfailedhandler(error:word);
+
+      {public in tlasio, and can't be private in both places, so should be public here. 
+      fixes delphi warning --beware}
+      {$ifdef win32}
+        procedure myfdclose(fd : integer); override;
+        function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; override;
+        function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; override;
+      {$endif}
+
     private
       {$ifdef ipv6}
         isv6socket : boolean; //identifies if the socket is v6, set by bindsocket
@@ -142,11 +151,6 @@ type
 
       procedure connecttimeouthandler(sender:tobject);
       procedure connectsuccesshandler;
-      {$ifdef win32}
-        procedure myfdclose(fd : integer); override;
-        function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; override;
-        function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; override;
-      {$endif}
     end;
     tsocket=longint; // for compatibility with twsocket
 
@@ -284,9 +288,6 @@ end;
 
 
 procedure tlsocket.connect;
-var
-  a:integer;
-  ip:tbinip;
 begin
   if state <> wsclosed then close;
   //prevtime := 0;
@@ -345,7 +346,6 @@ end;
 
 procedure tlsocket.bindsocket;
 var
-  a:integer;
   inAddrtemp:TInetSockAddrV;
   inAddrtempx:{$ifdef win32}winsock.TSockaddr{$else}TInetSockAddrV{$endif} absolute inaddrtemp;
   inaddrtempsize:integer;
@@ -380,7 +380,9 @@ end;
 
 procedure tlsocket.listen;
 var
+  {$ifndef win32}
   yes,no:longint;
+  {$endif}
   socktype:integer;
   biniptemp:tbinip;
   origaddr:thostname;
@@ -427,10 +429,11 @@ begin
   state := wsclosed; // then set this back as it was an undesired side effect of dup
 
   try
-    yes := $01010101;  {Copied this from existing code. Value is empiric,
-                    but works. (yes=true<>0) }
-    no := 0;
     {$ifndef win32}
+      yes := $01010101;  {Copied this from existing code. Value is empiric,
+                    but works. (yes=true<>0) }
+      no := 0;
+
       if SetSocketOptions(fdhandlein, SOL_SOCKET, SO_REUSEADDR,yes,sizeof(yes))=-1 then begin
         raise ESocketException.create('unable to set SO_REUSEADDR socket option');
       end;
@@ -552,7 +555,7 @@ begin
   if result > absoloutemaxs then begin
     myfdclose(result);
     a := result;
-    result := -1;
+{    result := -1;}
     raise esocketexception.create('file discriptor out of range: '+inttostr(a));
   end;
 end;