Use C++ language supported 'nullptr' (#13944)
This commit is contained in:
@ -55,7 +55,7 @@ void GcodeSuite::M421() {
|
||||
hasQ = !hasZ && parser.seen('Q');
|
||||
|
||||
if (hasC) {
|
||||
const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, NULL);
|
||||
const mesh_index_pair location = ubl.find_closest_mesh_point_of_type(REAL, current_position[X_AXIS], current_position[Y_AXIS], USE_NOZZLE_AS_REFERENCE, nullptr);
|
||||
ix = location.x_index;
|
||||
iy = location.y_index;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ float measuring_movement(const AxisEnum axis, const int dir, const bool stop_sta
|
||||
* axis in - Axis along which the measurement will take place
|
||||
* dir in - Direction along that axis (-1 or 1)
|
||||
* stop_state in - Move until probe pin becomes this value
|
||||
* backlash_ptr in/out - When not NULL, measure and record axis backlash
|
||||
* backlash_ptr in/out - When not nullptr, measure and record axis backlash
|
||||
* uncertainty in - If uncertainty is CALIBRATION_MEASUREMENT_UNKNOWN, do a fast probe.
|
||||
*/
|
||||
inline float measure(const AxisEnum axis, const int dir, const bool stop_state, float * const backlash_ptr, const float uncertainty) {
|
||||
|
@ -194,7 +194,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
|
||||
}
|
||||
SERIAL_ECHOPAIR(" block_found=", block_cnt);
|
||||
|
||||
if (block_cnt != 1 || __brkval != NULL)
|
||||
if (block_cnt != 1 || __brkval != nullptr)
|
||||
SERIAL_ECHOLNPGM("\nMemory Corruption detected in free memory area.");
|
||||
|
||||
if (block_cnt == 0) // Make sure the special case of no free blocks shows up as an
|
||||
@ -217,7 +217,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
|
||||
*/
|
||||
inline void free_memory_pool_report(char * const ptr, const int32_t size) {
|
||||
int32_t max_cnt = -1, block_cnt = 0;
|
||||
char *max_addr = NULL;
|
||||
char *max_addr = nullptr;
|
||||
// Find the longest block of test bytes in the buffer
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
char *addr = ptr + i;
|
||||
|
@ -80,7 +80,7 @@ GCodeParser parser;
|
||||
* this may be optimized by commenting out ZERO(param)
|
||||
*/
|
||||
void GCodeParser::reset() {
|
||||
string_arg = NULL; // No whole line argument
|
||||
string_arg = nullptr; // No whole line argument
|
||||
command_letter = '?'; // No command letter
|
||||
codenum = 0; // No command code
|
||||
#if USE_GCODE_SUBCODES
|
||||
@ -245,7 +245,7 @@ void GCodeParser::parse(char *p) {
|
||||
* This allows M0/M1 with expire time to work: "M0 S5 You Win!"
|
||||
* For 'M118' you must use 'E1' and 'A1' rather than just 'E' or 'A'
|
||||
*/
|
||||
string_arg = NULL;
|
||||
string_arg = nullptr;
|
||||
while (const char code = *p++) { // Get the next parameter. A NUL ends the loop
|
||||
|
||||
// Special handling for M32 [P] !/path/to/file.g#
|
||||
@ -289,7 +289,7 @@ void GCodeParser::parse(char *p) {
|
||||
#endif
|
||||
|
||||
#if ENABLED(FASTER_GCODE_PARSER)
|
||||
set(code, has_num ? p : NULL); // Set parameter exists and pointer (NULL for no number)
|
||||
set(code, has_num ? p : nullptr); // Set parameter exists and pointer (nullptr for no number)
|
||||
#endif
|
||||
}
|
||||
else if (!string_arg) { // Not A-Z? First time, keep as the string_arg
|
||||
@ -315,7 +315,7 @@ void GCodeParser::parse(char *p) {
|
||||
if (next_command) {
|
||||
while (*next_command && *next_command != ' ') ++next_command;
|
||||
while (*next_command == ' ') ++next_command;
|
||||
if (!*next_command) next_command = NULL;
|
||||
if (!*next_command) next_command = nullptr;
|
||||
}
|
||||
#else
|
||||
const char *next_command = command_args;
|
||||
|
@ -135,7 +135,7 @@ public:
|
||||
const bool b = TEST32(codebits, ind);
|
||||
if (b) {
|
||||
char * const ptr = command_ptr + param[ind];
|
||||
value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
|
||||
value_ptr = param[ind] && valid_float(ptr) ? ptr : nullptr;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
@ -178,7 +178,7 @@ public:
|
||||
static inline bool seen(const char c) {
|
||||
char *p = strchr(command_args, c);
|
||||
const bool b = !!p;
|
||||
if (b) value_ptr = valid_float(&p[1]) ? &p[1] : (char*)NULL;
|
||||
if (b) value_ptr = valid_float(&p[1]) ? &p[1] : nullptr;
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public:
|
||||
#endif
|
||||
|
||||
// The code value pointer was set
|
||||
FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
|
||||
FORCE_INLINE static bool has_value() { return value_ptr != nullptr; }
|
||||
|
||||
// Seen a parameter with a value
|
||||
static inline bool seenval(const char c) { return seen(c) && has_value(); }
|
||||
@ -224,20 +224,20 @@ public:
|
||||
if (c == '\0' || c == ' ') break;
|
||||
if (c == 'E' || c == 'e') {
|
||||
*e = '\0';
|
||||
const float ret = strtof(value_ptr, NULL);
|
||||
const float ret = strtof(value_ptr, nullptr);
|
||||
*e = c;
|
||||
return ret;
|
||||
}
|
||||
++e;
|
||||
}
|
||||
return strtof(value_ptr, NULL);
|
||||
return strtof(value_ptr, nullptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Code value as a long or ulong
|
||||
static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
|
||||
static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
|
||||
static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; }
|
||||
static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; }
|
||||
|
||||
// Code value for use as time
|
||||
static inline millis_t value_millis() { return value_ulong(); }
|
||||
|
@ -76,11 +76,11 @@ static int serial_count[NUM_SERIAL] = { 0 };
|
||||
bool send_ok[BUFSIZE];
|
||||
|
||||
/**
|
||||
* Next Injected Command pointer. NULL if no commands are being injected.
|
||||
* Next Injected Command pointer. nullptr if no commands are being injected.
|
||||
* Used by Marlin internally to ensure that commands initiated from within
|
||||
* are enqueued ahead of any pending serial or sd card commands.
|
||||
*/
|
||||
static PGM_P injected_commands_P = NULL;
|
||||
static PGM_P injected_commands_P = nullptr;
|
||||
|
||||
void queue_setup() {
|
||||
// Send "ok" after commands by default
|
||||
@ -157,7 +157,7 @@ bool enqueue_and_echo_command(const char* cmd) {
|
||||
* Return true if any immediate commands remain to inject.
|
||||
*/
|
||||
static bool drain_injected_commands_P() {
|
||||
if (injected_commands_P != NULL) {
|
||||
if (injected_commands_P != nullptr) {
|
||||
size_t i = 0;
|
||||
char c, cmd[60];
|
||||
strncpy_P(cmd, injected_commands_P, sizeof(cmd) - 1);
|
||||
@ -165,9 +165,9 @@ static bool drain_injected_commands_P() {
|
||||
while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
|
||||
cmd[i] = '\0';
|
||||
if (enqueue_and_echo_command(cmd)) // success?
|
||||
injected_commands_P = c ? injected_commands_P + i + 1 : NULL; // next command or done
|
||||
injected_commands_P = c ? injected_commands_P + i + 1 : nullptr; // next command or done
|
||||
}
|
||||
return (injected_commands_P != NULL); // return whether any more remain
|
||||
return (injected_commands_P != nullptr); // return whether any more remain
|
||||
}
|
||||
|
||||
/**
|
||||
@ -597,18 +597,18 @@ inline void get_serial_commands() {
|
||||
char* command = serial_line_buffer[i];
|
||||
|
||||
while (*command == ' ') command++; // Skip leading spaces
|
||||
char *npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line
|
||||
char *npos = (*command == 'N') ? command : nullptr; // Require the N parameter to start the line
|
||||
|
||||
if (npos) {
|
||||
|
||||
bool M110 = strstr_P(command, PSTR("M110")) != NULL;
|
||||
bool M110 = strstr_P(command, PSTR("M110")) != nullptr;
|
||||
|
||||
if (M110) {
|
||||
char* n2pos = strchr(command + 4, 'N');
|
||||
if (n2pos) npos = n2pos;
|
||||
}
|
||||
|
||||
gcode_N = strtol(npos + 1, NULL, 10);
|
||||
gcode_N = strtol(npos + 1, nullptr, 10);
|
||||
|
||||
if (gcode_N != gcode_LastN + 1 && !M110)
|
||||
return gcode_line_error(PSTR(MSG_ERR_LINE_NO), i);
|
||||
@ -617,7 +617,7 @@ inline void get_serial_commands() {
|
||||
if (apos) {
|
||||
uint8_t checksum = 0, count = uint8_t(apos - command);
|
||||
while (count) checksum ^= command[--count];
|
||||
if (strtol(apos + 1, NULL, 10) != checksum)
|
||||
if (strtol(apos + 1, nullptr, 10) != checksum)
|
||||
return gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH), i);
|
||||
}
|
||||
else
|
||||
@ -635,7 +635,7 @@ inline void get_serial_commands() {
|
||||
if (IsStopped()) {
|
||||
char* gpos = strchr(command, 'G');
|
||||
if (gpos) {
|
||||
switch (strtol(gpos + 1, NULL, 10)) {
|
||||
switch (strtol(gpos + 1, nullptr, 10)) {
|
||||
case 0:
|
||||
case 1:
|
||||
#if ENABLED(ARC_SUPPORT)
|
||||
|
Reference in New Issue
Block a user