cleanup: Do not return const values from functions
This generates a warning under -Wextra, since in most cases a const value doesn't prevent buggy code (as copies are allowed) while preventing some optimizations (such as move operations) to take place.
This commit is contained in:
parent
d6af13dfc1
commit
398a4bf403
|
|
@ -132,24 +132,24 @@ uint16_t PrusaErrorCode(uint8_t i){
|
|||
return pgm_read_word(errorCodes + i);
|
||||
}
|
||||
|
||||
const char * const PrusaErrorTitle(uint8_t i){
|
||||
return (const char * const)pgm_read_ptr(errorTitles + i);
|
||||
const char * PrusaErrorTitle(uint8_t i){
|
||||
return (const char *)pgm_read_ptr(errorTitles + i);
|
||||
}
|
||||
|
||||
const char * const PrusaErrorDesc(uint8_t i){
|
||||
return (const char * const)pgm_read_ptr(errorDescs + i);
|
||||
const char * PrusaErrorDesc(uint8_t i){
|
||||
return (const char *)pgm_read_ptr(errorDescs + i);
|
||||
}
|
||||
|
||||
uint8_t PrusaErrorButtons(uint8_t i){
|
||||
return pgm_read_byte(errorButtons + i);
|
||||
}
|
||||
|
||||
const char * const PrusaErrorButtonTitle(uint8_t bi){
|
||||
const char * PrusaErrorButtonTitle(uint8_t bi){
|
||||
// -1 represents the hidden NoOperation button which is not drawn in any way
|
||||
return (const char * const)pgm_read_ptr(btnOperation + bi - 1);
|
||||
return (const char *)pgm_read_ptr(btnOperation + bi - 1);
|
||||
}
|
||||
|
||||
const char * const PrusaErrorButtonMore(){
|
||||
const char * PrusaErrorButtonMore(){
|
||||
return _R(MSG_BTN_MORE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ uint8_t PrusaErrorCodeIndex(uint16_t ec);
|
|||
|
||||
/// @returns pointer to a PROGMEM string representing the Title of the Prusa-Error-Codes error
|
||||
/// @param i index of the error - obtained by calling ErrorCodeIndex
|
||||
const char * const PrusaErrorTitle(uint8_t i);
|
||||
const char * PrusaErrorTitle(uint8_t i);
|
||||
|
||||
/// @returns pointer to a PROGMEM string representing the multi-page Description of the Prusa-Error-Codes error
|
||||
/// @param i index of the error - obtained by calling ErrorCodeIndex
|
||||
const char * const PrusaErrorDesc(uint8_t i);
|
||||
const char * PrusaErrorDesc(uint8_t i);
|
||||
|
||||
/// @returns the actual numerical value of the Prusa-Error-Codes error
|
||||
/// @param i index of the error - obtained by calling ErrorCodeIndex
|
||||
|
|
@ -27,10 +27,10 @@ uint8_t PrusaErrorButtons(uint8_t i);
|
|||
|
||||
/// @returns pointer to a PROGMEM string representing the Title of a button
|
||||
/// @param i index of the error - obtained by calling PrusaErrorButtons + extracting low or high nibble from the Btns pair
|
||||
const char * const PrusaErrorButtonTitle(uint8_t bi);
|
||||
const char * PrusaErrorButtonTitle(uint8_t bi);
|
||||
|
||||
/// @returns pointer to a PROGMEM string representing the "More" button
|
||||
const char * const PrusaErrorButtonMore();
|
||||
const char * PrusaErrorButtonMore();
|
||||
|
||||
/// Sets the selected button for later pick-up by the MMU state machine.
|
||||
/// Used to save the GUI selection/decoupling
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ static const char * const progressTexts[] PROGMEM = {
|
|||
_R(MSG_PROGRESS_FEED_FSENSOR)
|
||||
};
|
||||
|
||||
const char * const ProgressCodeToText(uint16_t pc){
|
||||
const char * ProgressCodeToText(uint16_t pc){
|
||||
// @@TODO ?? a better fallback option?
|
||||
return ( pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) )
|
||||
? static_cast<const char * const>(pgm_read_ptr(&progressTexts[pc]))
|
||||
: static_cast<const char * const>(pgm_read_ptr(&progressTexts[0]));
|
||||
? static_cast<const char *>(pgm_read_ptr(&progressTexts[pc]))
|
||||
: static_cast<const char *>(pgm_read_ptr(&progressTexts[0]));
|
||||
}
|
||||
|
||||
} // namespace MMU2
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
namespace MMU2 {
|
||||
|
||||
const char * const ProgressCodeToText(uint16_t pc);
|
||||
const char * ProgressCodeToText(uint16_t pc);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace MMU2 {
|
||||
|
||||
const char * const ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together
|
||||
const char * ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together
|
||||
|
||||
void BeginReport(CommandInProgress cip, uint16_t ec) {
|
||||
custom_message_type = CustomMsg::MMUProgress;
|
||||
|
|
|
|||
Loading…
Reference in New Issue