Skip to content

Commit 5ffc5cc

Browse files
authored
Merge pull request #3838 from BsAtHome/fix_cppcheck-casts-copy
cppcheck: fix casts and copy constructors
2 parents 83f60a1 + 4738ebc commit 5ffc5cc

File tree

14 files changed

+118
-78
lines changed

14 files changed

+118
-78
lines changed

src/emc/ini/emcIniFile.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ EmcIniFile::ErrorCode
4343
EmcIniFile::Find(EmcJointType *result,
4444
const char *tag, const char *section, int num)
4545
{
46-
return(IniFile::Find((int *)result, jointTypeMap, tag, section, num));
46+
return(IniFile::Find(reinterpret_cast<int *>(result), jointTypeMap, tag, section, num));
4747
}
4848

4949

src/emc/nml_intf/emcops.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ EMC_MOTION_STAT::EMC_MOTION_STAT()
111111
external_offsets_applied(0),
112112
eoffset_pose{},
113113
numExtraJoints(0),
114-
jogging_active(0)
114+
jogging_active(0),
115+
heartbeat(0)
115116
{
116117
}
117118

src/emc/rs274ngc/interp_internal.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ struct setup
648648
setup();
649649
~setup();
650650

651+
// Not copyable
652+
setup(const setup&) = delete;
653+
setup& operator= (const setup&) = delete;
654+
651655
double AA_axis_offset; // A-axis g92 offset
652656
double AA_current; // current A-axis position
653657
double AA_origin_offset; // A-axis origin offset

src/emc/task/taskclass.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct _inittab builtin_modules[] = {
127127

128128
Task::Task(EMC_IO_STAT & emcioStatus_in) :
129129
emcioStatus(emcioStatus_in),
130+
iocontrol_data{},
130131
iocontrol("iocontrol.0"),
131132
ini_filename(emc_inifile),
132133
tool_status(0)

src/emc/tooldata/tooldata_nml.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ toolidx_t tooldata_get(CANON_TOOL_TABLE* pdata,int idx)
8585
return IDX_FAIL;
8686
}
8787

88-
*pdata = *(struct CANON_TOOL_TABLE*)(the_table + idx);
88+
*pdata = *reinterpret_cast<struct CANON_TOOL_TABLE*>(the_table + idx);
8989
return IDX_OK;
9090
} // tooldata_get()
9191

src/hal/user_comps/xhc-whb04b-6/hal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ class Hal
339339
public:
340340
Hal(Profiles::HalRequestProfile halRequestProfile=Profiles::halRequestSlowProfile());
341341
~Hal();
342+
343+
// Not copyable
344+
Hal(const Hal&) = delete;
345+
Hal& operator= (const Hal&) = delete;
346+
342347
//! Initializes HAL memory and pins according to simulation mode. Must not be called more than once.
343348
//! If \ref mIsSimulationMode is true heap memory will be used, shared HAL memory otherwise.
344349
//! \ref setIsSimulationMode() must be set before accordingly

src/libnml/cms/cms_aup.cc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int safe_strlen(char *string, int max)
224224
CMS_STATUS CMS_ASCII_UPDATER::update(bool &x)
225225
{
226226
/* Check to see if the pointers are in the proper range. */
227-
if (-1 == check_pointer((char *) &x, sizeof(bool))) {
227+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(bool))) {
228228
return (CMS_UPDATE_ERROR);
229229
}
230230

@@ -318,7 +318,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint8_t *x, unsigned int len)
318318
CMS_STATUS CMS_ASCII_UPDATER::update(int16_t &x)
319319
{
320320
/* Check to see if the pointers are in the proper range. */
321-
if (-1 == check_pointer((char *) &x, sizeof(int16_t))) {
321+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(int16_t))) {
322322
return (status = CMS_UPDATE_ERROR);
323323
}
324324

@@ -363,7 +363,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int16_t &x)
363363
CMS_STATUS CMS_ASCII_UPDATER::update(int16_t *x, unsigned int len)
364364
{
365365
/* Check to see if the pointers are in the proper range. */
366-
if (-1 == check_pointer((char *) x, sizeof(int16_t) * len)) {
366+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(int16_t) * len)) {
367367
return (status = CMS_UPDATE_ERROR);
368368
}
369369

@@ -378,7 +378,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int16_t *x, unsigned int len)
378378
CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t &x)
379379
{
380380
/* Check to see if the pointers are in the proper range. */
381-
if (-1 == check_pointer((char *) &x, sizeof(uint16_t))) {
381+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(uint16_t))) {
382382
return (status = CMS_UPDATE_ERROR);
383383
}
384384

@@ -423,7 +423,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t &x)
423423
CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t *x, unsigned int len)
424424
{
425425
/* Check to see if the pointers are in the proper range. */
426-
if (-1 == check_pointer((char *) x, sizeof(uint16_t) * len)) {
426+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(uint16_t) * len)) {
427427
return (status = CMS_UPDATE_ERROR);
428428
}
429429

@@ -440,7 +440,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t *x, unsigned int len)
440440
CMS_STATUS CMS_ASCII_UPDATER::update(int32_t &x)
441441
{
442442
/* Check to see if the pointers are in the proper range. */
443-
if (-1 == check_pointer((char *) &x, sizeof(int32_t))) {
443+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(int32_t))) {
444444
return (status = CMS_UPDATE_ERROR);
445445
}
446446

@@ -491,7 +491,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int32_t &x)
491491
CMS_STATUS CMS_ASCII_UPDATER::update(int32_t *x, unsigned int len)
492492
{
493493
/* Check to see if the pointers are in the proper range. */
494-
if (-1 == check_pointer((char *) x, sizeof(int32_t) * len)) {
494+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(int32_t) * len)) {
495495
return (status = CMS_UPDATE_ERROR);
496496
}
497497

@@ -506,7 +506,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int32_t *x, unsigned int len)
506506
CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t &x)
507507
{
508508
/* Check to see if the pointers are in the proper range. */
509-
if (-1 == check_pointer((char *) &x, sizeof(uint32_t))) {
509+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(uint32_t))) {
510510
return (status = CMS_UPDATE_ERROR);
511511
}
512512

@@ -557,7 +557,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t &x)
557557
CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t *x, unsigned int len)
558558
{
559559
/* Check to see if the pointers are in the proper range. */
560-
if (-1 == check_pointer((char *) x, sizeof(uint32_t) * len)) {
560+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(uint32_t) * len)) {
561561
return (status = CMS_UPDATE_ERROR);
562562
}
563563

@@ -574,7 +574,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t *x, unsigned int len)
574574
CMS_STATUS CMS_ASCII_UPDATER::update(int64_t &x)
575575
{
576576
/* Check to see if the pointers are in the proper range. */
577-
if (-1 == check_pointer((char *) &x, sizeof(int64_t))) {
577+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(int64_t))) {
578578
return (status = CMS_UPDATE_ERROR);
579579
}
580580

@@ -612,7 +612,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int64_t &x)
612612
CMS_STATUS CMS_ASCII_UPDATER::update(int64_t *x, unsigned int len)
613613
{
614614
/* Check to see if the pointers are in the proper range. */
615-
if (-1 == check_pointer((char *) x, sizeof(int64_t) * len)) {
615+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(int64_t) * len)) {
616616
return (status = CMS_UPDATE_ERROR);
617617
}
618618

@@ -627,7 +627,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int64_t *x, unsigned int len)
627627
CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t &x)
628628
{
629629
/* Check to see if the pointers are in the proper range. */
630-
if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) {
630+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(uint64_t))) {
631631
return (status = CMS_UPDATE_ERROR);
632632
}
633633

@@ -666,7 +666,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t &x)
666666
CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t *x, unsigned int len)
667667
{
668668
/* Check to see if the pointers are in the proper range. */
669-
if (-1 == check_pointer((char *) x, sizeof(uint64_t) * len)) {
669+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(uint64_t) * len)) {
670670
return (status = CMS_UPDATE_ERROR);
671671
}
672672

@@ -683,7 +683,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t *x, unsigned int len)
683683
CMS_STATUS CMS_ASCII_UPDATER::update(float &x)
684684
{
685685
/* Check to see if the pointers are in the proper range. */
686-
if (-1 == check_pointer((char *) &x, sizeof(float))) {
686+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(float))) {
687687
return (status = CMS_UPDATE_ERROR);
688688
}
689689

@@ -728,7 +728,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(float &x)
728728
CMS_STATUS CMS_ASCII_UPDATER::update(float *x, unsigned int len)
729729
{
730730
/* Check to see if the pointers are in the proper range. */
731-
if (-1 == check_pointer((char *) x, sizeof(float) * len)) {
731+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(float) * len)) {
732732
return (status = CMS_UPDATE_ERROR);
733733
}
734734

@@ -745,7 +745,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(float *x, unsigned int len)
745745
CMS_STATUS CMS_ASCII_UPDATER::update(double &x)
746746
{
747747
/* Check to see if the pointers are in the proper range. */
748-
if (-1 == check_pointer((char *) &x, sizeof(double))) {
748+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(double))) {
749749
return (status = CMS_UPDATE_ERROR);
750750
}
751751

@@ -783,7 +783,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(double &x)
783783
CMS_STATUS CMS_ASCII_UPDATER::update(double *x, unsigned int len)
784784
{
785785
/* Check to see if the pointers are in the proper range. */
786-
if (-1 == check_pointer((char *) x, sizeof(double) * len)) {
786+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(double) * len)) {
787787
return (status = CMS_UPDATE_ERROR);
788788
}
789789

@@ -800,7 +800,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(double *x, unsigned int len)
800800
CMS_STATUS CMS_ASCII_UPDATER::update(long double &x)
801801
{
802802
/* Check to see if the pointers are in the proper range. */
803-
if (-1 == check_pointer((char *) &x, sizeof(long double))) {
803+
if (-1 == check_pointer(reinterpret_cast<char *>(&x), sizeof(long double))) {
804804
return (status = CMS_UPDATE_ERROR);
805805
}
806806

@@ -838,7 +838,7 @@ CMS_STATUS CMS_ASCII_UPDATER::update(long double &x)
838838
CMS_STATUS CMS_ASCII_UPDATER::update(long double *x, unsigned int len)
839839
{
840840
/* Check to see if the pointers are in the proper range. */
841-
if (-1 == check_pointer((char *) x, sizeof(long double) * len)) {
841+
if (-1 == check_pointer(reinterpret_cast<char *>(x), sizeof(long double) * len)) {
842842
return (status = CMS_UPDATE_ERROR);
843843
}
844844

src/libnml/cms/cms_cfg.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ struct CONFIG_FILE_INFO {
7474
}
7575
};
7676

77+
// Not copyable
78+
CONFIG_FILE_INFO(const CONFIG_FILE_INFO&) = delete;
79+
CONFIG_FILE_INFO& operator= (const CONFIG_FILE_INFO&) = delete;
80+
7781
LinkedList *lines_list;
7882
char file_name[80];
7983
};

0 commit comments

Comments
 (0)