Comments (5)
Hi Garry,
Thanks for using RunCPM.
This is strange.
I have just compiled RunCPM for my Arduino Due and didn't get any warnings. I am using Arduino 1.8.9 too, which I have just installed. SdFat by Bill Greiman version 1.1.0.
Did you make any change to any configuration that you would remember? Maybe to compile a different project? Maybe you're not using the regular Greiman's SdFat library?
This is the definition of f.write() inside the library:
/** Write a single byte.
* \param[in] b The byte to be written.
* \return +1 for success or -1 for failure.
*/
int write(uint8_t b) {
return write(&b, 1);
}
So it is supposed to be less than 0 if there's an error.
The return value of this function is not unsigned, so nothing to fix there.
Please check it out and let me know. I am happy to assist more if needed.
Cheers,
Marcelo.
from runcpm.
Marcelo,
Correct, however, when I compile original (unmodified) RunCPM, using SDFat library with 1 file modified, I get a warning that is critical. It shows the code will never be executed.
Here is what I did:
Copy extracted RunCPM distro into my Sketch subdir with name RunCPM
Start Arduino IDE
Manage Libraries -> Install "SDFat library version 1.1.0".
Edit SdFatConfig.h in actual disk install location, per this info in RunCpm.ino:
// SdFatSoftSpiEX and SdFatEX require changes to the following lines on SdFatConfig.h:
// #define ENABLE_EXTENDED_TRANSFER_CLASS (from 0 to 1 - around line 71)
// #define ENABLE_SOFTWARE_SPI_CLASS (from 0 to 1 - around line 87)
Restart Arduino IDE
Preferences -> "Show verbose output during compiling" -> Compiler warnings -> "ALL"
Load RunCPM sketch
Compile Sketch
The following "Warning" is displayed:
In file included from C:\Users\kraemerg\Documents\Arduino\Sketches\RunCPM\RunCPM\RunCPM.ino:49:0:
C:\Users\kraemerg\AppData\Local\Temp\arduino_build_251570\sketch\abstraction_arduino.h: In function 'bool _sys_extendfile(char*, long unsigned int)':
C:\Users\kraemerg\AppData\Local\Temp\arduino_build_251570\sketch\abstraction_arduino.h:171:31: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if ((f.write((uint8_t)0)) < 0) {
^
The Warning states the "If statement will never be executed (entered)!
Casting the f.write() return value stops the warning.
if ((int)(f.write((uint8_t)0)) < 0) {
result = false;
break;
}
I'm not sure if this is the correct way to fix the issue.
Thanks
Garry
from runcpm.
Marcelo,
This looks to be the way to fix the routine:
bool _sys_extendfile(char *fn, unsigned long fpos)
{
uint8 result = true;
File f;
unsigned long i;
int zero = 0;
digitalWrite(LED, HIGH^LEDinv);
if (f = SD.open(fn, O_WRITE | O_APPEND)) {
if (fpos > f.size()) {
for (i = 0; i < f.size() - fpos; ++i) {
if ((f.write((uint8_t)0)) < zero) {
result = false;
break;
}
}
}
f.close();
} else {
result = false;
}
digitalWrite(LED, LOW^LEDinv);
return(result);
}
Declaring a local integer value 'zero' and initializing it makes sure it is an integer.
Now the logical test using the f.write return value properly compares the integer variable 'zero'
I still don't understand exactly why '0' is unsigned, unless it is treated as a character.
I have never run into this in 20 years of software engineering.
Garry
from runcpm.
Yes, this is very strange ... if the compiler is not dumb (which seems to be the case) it should just interpret the numeric value as having the same type as to the expression to the left, being it a constant.
But anyways, one more compiler quirk that we have to work around. I will make the change to the official code branch, as I hate warnings too. :)
from runcpm.
I have changed the code to:
if (f.write((uint8_t)0) != 1)
This should work as the library states it returns 1 for success.
So no more warning, please run some tests if possible.
from runcpm.
Related Issues (20)
- Build errors in cpm.h HOT 4
- Allow RunCPM to be used as a Github Action for SUBMIT jobs. HOT 4
- COPY program HOT 5
- Transverse (copy/execute) between slices HOT 1
- Going Crazt HOT 4
- CCP-ZCP3.60K HOT 1
- Feature request: Console on ESP32 TTL Serial port HOT 9
- BASIC/Z compiler not supported HOT 3
- NULU open lbr files does not work HOT 9
- saving/loading Problem with HEBAS under RunCPM HOT 2
- Bdos Err on M: Select when I try ASM DUMP.ASM HOT 2
- ESP32-Wrover kit freeze HOT 8
- Request: Simple variation on LED.BAS as a Hello World using BDOS 9 HOT 3
- [Q] Difference for RunCPM between TYPE and TYPE in a .SUB? HOT 4
- [Q] How about updateing to LUA v5.4.6? HOT 2
- Command switch to select base virtual-disk directory HOT 2
- Builds break after moving Lua in git submodule HOT 1
- Z80ASM (and M80) hang HOT 4
- 8085 and APU/FPU HOT 3
- Unable to build latest main branch HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runcpm.