Git Product home page Git Product logo

Comments (5)

vpelletier avatar vpelletier commented on August 14, 2024

There is another warning about an uninitialised variable in one of the functions called from there: writeFlashBuffer_N64.

In that case it is a bit clearer that this should not be an issue: the variable would be uninitialised if bufferSize is 0, which seem unlikely to happen (...if the caller takes care to never provide 0, but the caller has bigger issues).

from cartreader.

sanni avatar sanni commented on August 14, 2024

You can initialize them to a value of zero if it removes the warning. In the case that they are needed they get new values anyway in the two switch cases.

from cartreader.

vpelletier avatar vpelletier commented on August 14, 2024

Do they ? The switch blocks are only for the case where cartSize == 0 (the else branch). The only lines outside of that branch which touch these variables are:

void flashRepro_N64() {
  unsigned long sectorSize;
  byte bufferSize;
// ...
      } else if (bufferSize == 0) {
        writeFlashrom_N64(sectorSize);
      } else {
        writeFlashBuffer_N64(sectorSize, bufferSize);
      }

Also, setting to zero will cause another issue in writeFlashBuffer_N64. EDIT: this is incorrect, the code will go to writeFlashrom_N64 if bufferSize is zero. But there it will cause an infinite loop:

void writeFlashrom_N64(unsigned long sectorSize) {
// ...
  for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) {

sectorSize is zero, so the increment is zero, so currSector will never reach fileSize.

So I think there is more to fix here, but I do not know enough to tell exactly how it should be fixed.

from cartreader.

sanni avatar sanni commented on August 14, 2024

I see, maybe like this:

// ...
} else if ((bufferSize == 0) && (sectorSize != 0))  {
        writeFlashrom_N64(sectorSize);
} 
else if (sectorSize != 0) {
        writeFlashBuffer_N64(sectorSize, bufferSize);
}
else {
       print_Error(F("sectorSize not set"), true);
}

from cartreader.

vpelletier avatar vpelletier commented on August 14, 2024

Thanks, applied.

from cartreader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.