]> granicus.if.org Git - graphviz/commit
gvc: use 'int' when converting SVG units
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 11 Nov 2022 03:39:48 +0000 (19:39 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 11 Nov 2022 03:39:48 +0000 (19:39 -0800)
commit020126f9f295dfcb7a6b0ad86f4b0b687a26d02b
tree1a9646ffe84a950ee727ad3c79010c3fe48eeb83
parent645f5edce1de092f3aae60563477eb1a350f7f57
gvc: use 'int' when converting SVG units

These values are eventually stored in `int` fields, so going through
`unsigned int` is unproductive. This squashes a number of warnings:

  In file included from ../../lib/common/geom.h:19,
                   from ../../lib/common/types.h:37,
                   from gvusershape.c:28:
  gvusershape.c: In function ‘svg_units_convert’:
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:149:16: note: in expansion of macro ‘ROUND’
    149 |         return ROUND(n * POINTS_PER_INCH);
        |                ^~~~~
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:151:16: note: in expansion of macro ‘ROUND’
    151 |         return ROUND(n * POINTS_PER_INCH / 96);
        |                ^~~~~
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:153:16: note: in expansion of macro ‘ROUND’
    153 |         return ROUND(n * POINTS_PER_INCH / 6);
        |                ^~~~~
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:155:16: note: in expansion of macro ‘ROUND’
    155 |         return ROUND(n);
        |                ^~~~~
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:157:16: note: in expansion of macro ‘ROUND’
    157 |         return ROUND(n * POINTS_PER_CM);
        |                ^~~~~
  ../../lib/common/arith.h:59:46: warning: conversion to ‘unsigned int’ from
    ‘int’ may change the sign of the result [-Wsign-conversion]
     59 | #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  gvusershape.c:159:16: note: in expansion of macro ‘ROUND’
    159 |         return ROUND(n * POINTS_PER_MM);
        |                ^~~~~
  gvusershape.c:261:13: warning: conversion to ‘int’ from ‘unsigned int’ may
    change the sign of the result [-Wsign-conversion]
    261 |     us->w = w;
        |             ^
  gvusershape.c:262:13: warning: conversion to ‘int’ from ‘unsigned int’ may
    change the sign of the result [-Wsign-conversion]
    262 |     us->h = h;
        |             ^
lib/gvc/gvusershape.c