da ich mit jeder neuen IDE Version einen kleinen SD Bugfix mit rübernehme, fiel mir jetzt was auf.
Irgendwas für mich unklares wurde geändert.
In Funktion Deklarationen wurden Variablen auskommentiert, sodass der Datentyp alleine da steht.
Ich vergleiche das mit notepadd++ und dem compare plugin.
die Codestellen sehen mir eher nach den Definitionen der Funktionen aus, nicht nach Deklarationen, wegen der öffnenden Klammern am Ende.
Kann es sein, dass diese Parameter nicht mehr verwendet werden, aber aus Kompatibilitätsgründen (aufrufender Code) weiter vorhanden sein müssen ? Wenn sie keinen Namen mehr haben, kann man sie im Code nicht mehr verwenden ohne eine Fehlermeldung zu bekommen.
ein Problem habe ich noch. Die IDE meckert rum wegen dem nicht initialisierten int pathidx
Was open.constprop sein soll weiß ich nicht, die Funktion gibts nicht.
Seltsamerweise wird das nicht initialisierte int pathidx erst mit der aktuellen IDE Version angemeckert.
Die Funktion steht so auch in der alten schon drin.
Es müßte doch reichen wenn ich
int pathidx = 0;
schreibe?
C:\Program Files (x86)\Arduino\libraries\SD\src\SD.cpp: In function 'open.constprop':
C:\Program Files (x86)\Arduino\libraries\SD\src\SD.cpp:442:12: warning: 'pathidx' may be used uninitialized in this function [-Wmaybe-uninitialized]
filepath += pathidx;
^
C:\Program Files (x86)\Arduino\libraries\SD\src\SD.cpp:436:7: note: 'pathidx' was declared here
int pathidx;
^
File SDClass::open(const char *filepath, uint8_t mode) {
/*
Open the supplied file path for reading or writing.
The file content can be accessed via the `file` property of
the `SDClass` object--this property is currently
a standard `SdFile` object from `sdfatlib`.
Defaults to read only.
If `write` is true, default action (when `append` is true) is to
append data to the end of the file.
If `append` is false then the file will be truncated first.
If the file does not exist and it is opened for writing the file
will be created.
An attempt to open a file for reading that does not exist is an
error.
*/
int pathidx;
// do the interative search
SdFile parentdir = getParentDir(filepath, &pathidx);
// no more subdirs!
filepath += pathidx;
if (! filepath[0]) {
// it was the directory itself!
return File(parentdir, "/");
}
// Open the file itself
SdFile file;
// failed to open a subdir!
if (!parentdir.isOpen())
return File();
// there is a special case for the Root directory since its a static dir
if (parentdir.isRoot()) {
if ( ! file.open(root, filepath, mode)) {
// failed to open the file :(
return File();
}
// dont close the root!
} else {
if ( ! file.open(parentdir, filepath, mode)) {
return File();
}
// close the parent
parentdir.close();
}
if (mode & (O_APPEND | O_WRITE))
file.seekSet(file.fileSize());
return File(file, filepath);
}
Doc_Arduino:
Es müßte doch reichen wenn ich
int pathidx = 0;
schreibe?
Ich würde sagen ja, so wie der Code aussieht, scheint pathidx ja ein reiner Rückgabewert von getParentDir zu sein. Ist das vielleicht auch so ein "überflüssiger" Parameter ?
Muss ich mir mal bei den großen Teensys ansehen, sonst habe ich nichts mit SD-Karte.
spätestens mit filepath addiert wird er zum Rückgabewert. Wenn dann in pathidx zufälligerweise Müll drin steht, kommt Unsinn raus. Hab pathidx erstmal mit 0 definiert. Lernt man auch so.