summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-04-01 12:52:05 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-04-01 12:52:05 -0700
commit103579f030bfead4a1f821734dd6dbaf823c5527 (patch)
treecaec556059b3838deefa7a7999db4958f1399e7f /util.c
parent4208f2d0dd928a2e627a2284337302be62b3967a (diff)
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/util.c b/util.c
index 655b5cf..32460b1 100644
--- a/util.c
+++ b/util.c
@@ -132,12 +132,11 @@ vsprintf_alloc(const char *f, va_list args)
char *
makeUTF16(const char *string)
{
- int i;
int n = strlen(string);
char *value = malloc(2 * n);
if(!value)
return NULL;
- for(i = 0; i < n; i++) {
+ for(int i = 0; i < n; i++) {
value[2 * i] = '\0';
value[2 * i + 1] = string[i];
}
@@ -445,7 +444,6 @@ degreesToFraction(int deg, int *num, int *den)
{
double n, d;
double rad, val;
- int i;
if(deg <= -(60 * TWO_SIXTEENTH) || deg >= (60 * TWO_SIXTEENTH))
goto fail;
@@ -460,7 +458,7 @@ degreesToFraction(int deg, int *num, int *den)
val = atan2(n, d);
/* There must be a cleaner way */
- for(i = 1; i < 10000; i++) {
+ for(int i = 1; i < 10000; i++) {
if((int)(d * i) != 0.0 &&
fabs(atan2(ROUND(n * i), ROUND(d * i)) - val) < 0.05) {
*num = (int)ROUND(n * i);