Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning "'next' may be used uninitialized in this function" #72

Closed
FrankBoesing opened this issue Jun 29, 2021 · 3 comments
Closed

Warning "'next' may be used uninitialized in this function" #72

FrankBoesing opened this issue Jun 29, 2021 · 3 comments

Comments

@FrankBoesing
Copy link

if ((cluster + 1) != next || status == 0) {

GCC 10 prints the mentioned warning.

@greiman
Copy link
Owner

greiman commented Jun 29, 2021

next should be set at line 225 by this if status is one.

    status = fatGet(cluster, &next);
    if (status < 0) {
      DBG_FAIL_MACRO;
      goto fail;
    }

I will double check fatGet since is may have a problem.

@greiman greiman closed this as completed Jun 29, 2021
@greiman
Copy link
Owner

greiman commented Jun 29, 2021

It appears the program works OK but I made two changes that may suppress the warning.

First the return type of fatGet is wrong. it should be int8_t but all calls use int8_t for tests.

next is not used unless the return status is one. I changed this test to not use next unless status is one.

if (status == 0 || (cluster + 1) != next) {

I should probably change the loop to not execute these assigns before returning.

      start = next;
    }
    cluster = next;
  } while (status);

I did change fatGet to set next to EOC for return 0 so the compiler should not give the warning. If EOC is used, a crash or error will occur.

@FrankBoesing
Copy link
Author

Thank you, Bill !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants