Fix 10 compiler warnings of type: sketch/menu.cpp: In function 'void _menu_edit_int3()':

sketch/menu.cpp:272:51: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 #define _menu_data (*((menu_data_edit_t*)menu_data))
This commit is contained in:
Marek Bel 2018-08-01 22:37:10 +02:00
parent 93d2b37b5c
commit ef8921d45e
3 changed files with 88 additions and 80 deletions

View File

@ -8,6 +8,7 @@
#include "lcd.h"
#include "Configuration.h"
#include "Marlin.h"
#include "ultralcd.h"
@ -269,7 +270,7 @@ void menu_draw_float13(char chr, const char* str, float val)
lcd_printf_P(menu_fmt_float13, chr, str, spaces, val);
}
#define _menu_data (*((menu_data_edit_t*)menu_data))
#define _menu_data menuData.edit_menu
void _menu_edit_int3(void)
{
if (lcd_draw_update)

View File

@ -48,85 +48,6 @@ char longFilenameOLD[LONG_FILENAME_LENGTH];
static void lcd_sd_updir();
struct EditMenuParentState
{
//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
menu_func_t prevMenu;
uint16_t prevEncoderPosition;
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue, maxEditValue;
// menu_func_t callbackFunc;
};
union MenuData
{
struct BabyStep
{
// 29B total
int8_t status;
int babystepMem[3];
float babystepMemMM[3];
} babyStep;
struct SupportMenu
{
// 6B+16B=22B total
int8_t status;
bool is_flash_air;
uint8_t ip[4];
char ip_str[3*4+3+1];
} supportMenu;
struct AdjustBed
{
// 6+13+16=35B
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
int8_t status;
int8_t left;
int8_t right;
int8_t front;
int8_t rear;
int left2;
int right2;
int front2;
int rear2;
} adjustBed;
struct TuneMenu
{
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
// To recognize, whether the menu has been just initialized.
int8_t status;
// Backup of extrudemultiply, to recognize, that the value has been changed and
// it needs to be applied.
int16_t extrudemultiply;
} tuneMenu;
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
struct AutoLoadFilamentMenu
{
//ShortTimer timer;
char dummy;
} autoLoadFilamentMenu;
struct _Lcd_moveMenu
{
bool initialized;
bool endstopsEnabledPrevious;
} _lcd_moveMenu;
struct sdcard_menu_t
{
uint8_t viewState;
} sdcard_menu;
};
// State of the currently active menu.
// C Union manages sharing of the static memory by all the menus.

View File

@ -4,6 +4,7 @@
#include "Marlin.h"
#include "lcd.h"
#include "conv2str.h"
#include "menu.h"
extern int lcd_puts_P(const char* str);
extern int lcd_printf_P(const char* format, ...);
@ -12,6 +13,91 @@ extern void menu_lcd_longpress_func(void);
extern void menu_lcd_charsetup_func(void);
extern void menu_lcd_lcdupdate_func(void);
struct EditMenuParentState
{
//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
menu_func_t prevMenu;
uint16_t prevEncoderPosition;
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue, maxEditValue;
// menu_func_t callbackFunc;
};
union MenuData
{
struct BabyStep
{
// 29B total
int8_t status;
int babystepMem[3];
float babystepMemMM[3];
} babyStep;
struct SupportMenu
{
// 6B+16B=22B total
int8_t status;
bool is_flash_air;
uint8_t ip[4];
char ip_str[3*4+3+1];
} supportMenu;
struct AdjustBed
{
// 6+13+16=35B
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
int8_t status;
int8_t left;
int8_t right;
int8_t front;
int8_t rear;
int left2;
int right2;
int front2;
int rear2;
} adjustBed;
struct TuneMenu
{
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
// To recognize, whether the menu has been just initialized.
int8_t status;
// Backup of extrudemultiply, to recognize, that the value has been changed and
// it needs to be applied.
int16_t extrudemultiply;
} tuneMenu;
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
struct AutoLoadFilamentMenu
{
//ShortTimer timer;
char dummy;
} autoLoadFilamentMenu;
struct _Lcd_moveMenu
{
bool initialized;
bool endstopsEnabledPrevious;
} _lcd_moveMenu;
struct sdcard_menu_t
{
uint8_t viewState;
} sdcard_menu;
menu_data_edit_t edit_menu;
};
// State of the currently active menu.
// C Union manages sharing of the static memory by all the menus.
extern union MenuData menuData;
// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
void ultralcd_init();