<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 17, 2015 at 6:08 PM, Pavel Grunt <span dir="ltr"><<a href="mailto:pgrunt@redhat.com" target="_blank">pgrunt@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, 2015-08-17 at 17:55 +0200, Fabiano Fidêncio wrote:<br>
> Coverity says:<br>
> Result is not floating-point (UNINTENDED_INTEGER_DIVISION)<br>
> interger_division: Dividing integer expressions "preferred->width * 100"<br>
> and "zoom", and then converting the integer quotient to type double. Any<br>
> remainder, or fractional part of the quotient, is ignored.<br>
<br>
</span>I think it is better to remove the round(), otherwise you are changing the<br>
behavior (which is there since 33614f86db490364339ef69e0eb76f98a4ac8138).<br></blockquote><div><br></div><div>I don't see why I am (wrongly) changing the behavior, Pavel.<br></div><div>Can you give me an example?<br></div><div><br></div><div>Nowadays, using the round or not using the round would end up in the same result and I don't think it's the expected/correct behavior.<br></div><div><br>Let's consider: width = 640, NORMAL_ZOOM_LEVEL = 100, zoom = 85.<br><br></div><div>Current behavior:<br></div><div>width = round (640*100/85)<br>width = round (752)<br>width = 752.<br><br></div><div>Removing the round:<br></div><div>width = 640*100/85<br>width = 752</div><div><br></div><div>What I consider the expected behavior: <br>width = round (640*100/85)<br>width = round (752.94)<br>width = 753<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Or is the rounding necessary ?<br></blockquote><div><br></div><div>I do think so.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Pavel<br>
</font></span><div class="HOEnZb"><div class="h5">> ---<br>
>  src/virt-viewer-display.c | 4 ++--<br>
>  1 file changed, 2 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c<br>
> index 3efe24c..8431ae4 100644<br>
> --- a/src/virt-viewer-display.c<br>
> +++ b/src/virt-viewer-display.c<br>
> @@ -819,8 +819,8 @@ void<br>
> virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,<br>
>      if (virt_viewer_display_get_zoom(VIRT_VIEWER_DISPLAY(self))) {<br>
>          guint zoom =<br>
> virt_viewer_display_get_zoom_level(VIRT_VIEWER_DISPLAY(self));<br>
><br>
> -        preferred->width = round(preferred->width * NORMAL_ZOOM_LEVEL /<br>
> zoom);<br>
> -        preferred->height = round(preferred->height * NORMAL_ZOOM_LEVEL /<br>
> zoom);<br>
> +        preferred->width = round(preferred->width * NORMAL_ZOOM_LEVEL /<br>
> (double) zoom);<br>
> +        preferred->height = round(preferred->height * NORMAL_ZOOM_LEVEL /<br>
> (double) zoom);<br>
>      }<br>
>  }<br>
><br>
</div></div></blockquote></div><br><br clear="all"></div><div class="gmail_extra">Thanks for the review,<br></div><div class="gmail_extra">-- <br><div class="gmail_signature"><div dir="ltr">Fabiano Fidêncio<br></div></div>
</div></div>