Skip to content

Return values are counted as globals #16

Description

@MartinCowen

As an example, I have the following as the total contents of a file called sample1.c

#include <stdint.h>

uint8_t ctof_truncates(uint8_t c)
{	//simple version, rounds fractions down
	uint8_t i;

	if (c < 255 / 9)
	{
		i = c * 9;
		i /= 5;
	}
	else
	{
		i = c / 5;
		i *= 9;
	}

	i += 32;

	return i;
}

for which the command ravioli -f sample1.c produces the output


-------------------------------------------------------------------------------
Globals
-------------------------------------------------------------------------------
sample1.c:21 i
-------------------------------------------------------------------------------
Functions                                                            complexity
-------------------------------------------------------------------------------
sample1.c:4
    ctof_truncates

but i is declared within the scope of the function, and the line which ravioli complains about is the return i statement.
I have found that it does not count i as global if that line is changed to return (i); but this is more of a hint than a workaround since ravioli is supposed to be used with existing code.
Maybe this problem did not exist in earlier versions because your readme file shows FreeRTOS\tasks.c with zero globals but ravioli 0.3.0 shows 64 globals, many of which are xReturn or break

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions