minor compiler warning in backend/utils/adt/tsrank.c - Mailing list pgsql-hackers

From Hannes Eder
Subject minor compiler warning in backend/utils/adt/tsrank.c
Date
Msg-id 46F26230.5090302@HannesEder.net
Whole thread Raw
Responses Re: [PATCHES] minor compiler warning in backend/utils/adt/tsrank.c
List pgsql-hackers
while rebuilding postgres with msvc 2005 I noticed some minor compiler
warnings:

.\src\backend\utils\adt\tsrank.c(24): warning C4305: 'initializing' :
truncation from 'double' to 'float'
.\src\backend\utils\adt\tsrank.c(24): warning C4305: 'initializing' :
truncation from 'double' to 'float'
.\src\backend\utils\adt\tsrank.c(24): warning C4305: 'initializing' :
truncation from 'double' to 'float'
.\src\backend\utils\adt\tsrank.c(46): warning C4305: 'return' :
truncation from 'double' to 'float4'
.\src\backend\utils\adt\tsrank.c(339): warning C4305: '=' : truncation
from 'double' to 'float'

see attached diff

-Hannes

*** ../pgsql-cvshead/src/backend/utils/adt/tsrank.c    Thu Sep 20 10:30:19 2007
--- src/backend/utils/adt/tsrank.c    Thu Sep 20 12:20:10 2007
***************
*** 21,27 ****
  #include "miscadmin.h"


! static float weights[] = {0.1, 0.2, 0.4, 1.0};

  #define wpos(wep)    ( w[ WEP_GETWEIGHT(wep) ] )

--- 21,27 ----
  #include "miscadmin.h"


! static float weights[] = {0.1f, 0.2f, 0.4f, 1.0f};

  #define wpos(wep)    ( w[ WEP_GETWEIGHT(wep) ] )

***************
*** 43,49 ****
  word_distance(int4 w)
  {
      if (w > 100)
!         return 1e-30;

      return 1.0 / (1.005 + 0.05 * exp(((float4) w) / 1.5 - 2));
  }
--- 43,49 ----
  word_distance(int4 w)
  {
      if (w > 100)
!         return 1e-30f;

      return 1.0 / (1.005 + 0.05 * exp(((float4) w) / 1.5 - 2));
  }
***************
*** 336,342 ****
          calc_rank_and(w, t, q) : calc_rank_or(w, t, q);

      if (res < 0)
!         res = 1e-20;

      if ((method & RANK_NORM_LOGLENGTH) && t->size > 0)
          res /= log((double) (cnt_length(t) + 1)) / log(2.0);
--- 336,342 ----
          calc_rank_and(w, t, q) : calc_rank_or(w, t, q);

      if (res < 0)
!         res = 1e-20f;

      if ((method & RANK_NORM_LOGLENGTH) && t->size > 0)
          res /= log((double) (cnt_length(t) + 1)) / log(2.0);

pgsql-hackers by date:

Previous
From: Hannes Eder
Date:
Subject: compiler warnings in ecpglib/execute.c (uninitialized local variable 'prepname' used)
Next
From: Martin Pihlak
Date:
Subject: Re: stored procedure stats in collector