Skip to content

Commit 4fdf272

Browse files
committed
Remove checks for this == NULL
This fixes warnings from clang. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 20e3b21 commit 4fdf272

File tree

8 files changed

+8
-207
lines changed

8 files changed

+8
-207
lines changed

ccstruct/split.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,8 @@ void remove_edgept(EDGEPT *point) {
225225
* Shows the coordinates of both points in a split.
226226
**********************************************************************/
227227
void SPLIT::Print() const {
228-
if (this != NULL) {
229-
tprintf("(%d,%d)--(%d,%d)", point1->pos.x, point1->pos.y, point2->pos.x,
230-
point2->pos.y);
231-
}
228+
tprintf("(%d,%d)--(%d,%d)", point1->pos.x, point1->pos.y, point2->pos.x,
229+
point2->pos.y);
232230
}
233231

234232
#ifndef GRAPHICS_DISABLED

ccutil/clst.cpp

-35
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ void (*zapper) (void *)) { //ptr to zapper functn
4343
CLIST_LINK *ptr;
4444
CLIST_LINK *next;
4545

46-
#ifndef NDEBUG
47-
if (!this)
48-
NULL_OBJECT.error ("CLIST::internal_deep_clear", ABORT, NULL);
49-
#endif
50-
5146
if (!empty ()) {
5247
ptr = last->next; //set to first
5348
last->next = NULL; //break circle
@@ -75,11 +70,6 @@ void CLIST::shallow_clear() { //destroy all links
7570
CLIST_LINK *ptr;
7671
CLIST_LINK *next;
7772

78-
#ifndef NDEBUG
79-
if (!this)
80-
NULL_OBJECT.error ("CLIST::shallow_clear", ABORT, NULL);
81-
#endif
82-
8373
if (!empty ()) {
8474
ptr = last->next; //set to first
8575
last->next = NULL; //break circle
@@ -111,11 +101,6 @@ void CLIST::assign_to_sublist( //to this list
111101
const ERRCODE LIST_NOT_EMPTY =
112102
"Destination list must be empty before extracting a sublist";
113103

114-
#ifndef NDEBUG
115-
if (!this)
116-
NULL_OBJECT.error ("CLIST::assign_to_sublist", ABORT, NULL);
117-
#endif
118-
119104
if (!empty ())
120105
LIST_NOT_EMPTY.error ("CLIST.assign_to_sublist", ABORT, NULL);
121106

@@ -133,11 +118,6 @@ inT32 CLIST::length() const { //count elements
133118
CLIST_ITERATOR it(const_cast<CLIST*>(this));
134119
inT32 count = 0;
135120

136-
#ifndef NDEBUG
137-
if (!this)
138-
NULL_OBJECT.error ("CLIST::length", ABORT, NULL);
139-
#endif
140-
141121
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward())
142122
count++;
143123
return count;
@@ -160,11 +140,6 @@ const void *, const void *)) {
160140
void **current;
161141
inT32 i;
162142

163-
#ifndef NDEBUG
164-
if (!this)
165-
NULL_OBJECT.error ("CLIST::sort", ABORT, NULL);
166-
#endif
167-
168143
/* Allocate an array of pointers, one per list element */
169144
count = length ();
170145
base = (void **) malloc (count * sizeof (void *));
@@ -272,8 +247,6 @@ void CLIST::set_subtract(int comparator(const void*, const void*),
272247

273248
void *CLIST_ITERATOR::forward() {
274249
#ifndef NDEBUG
275-
if (!this)
276-
NULL_OBJECT.error ("CLIST_ITERATOR::forward", ABORT, NULL);
277250
if (!list)
278251
NO_LIST.error ("CLIST_ITERATOR::forward", ABORT, NULL);
279252
#endif
@@ -317,8 +290,6 @@ void *CLIST_ITERATOR::data_relative( //get data + or - ...
317290
CLIST_LINK *ptr;
318291

319292
#ifndef NDEBUG
320-
if (!this)
321-
NULL_OBJECT.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
322293
if (!list)
323294
NO_LIST.error ("CLIST_ITERATOR::data_relative", ABORT, NULL);
324295
if (list->empty ())
@@ -352,8 +323,6 @@ void *CLIST_ITERATOR::data_relative( //get data + or - ...
352323

353324
void *CLIST_ITERATOR::move_to_last() {
354325
#ifndef NDEBUG
355-
if (!this)
356-
NULL_OBJECT.error ("CLIST_ITERATOR::move_to_last", ABORT, NULL);
357326
if (!list)
358327
NO_LIST.error ("CLIST_ITERATOR::move_to_last", ABORT, NULL);
359328
#endif
@@ -386,8 +355,6 @@ void CLIST_ITERATOR::exchange( //positions of 2 link
386355
CLIST_LINK *old_current;
387356

388357
#ifndef NDEBUG
389-
if (!this)
390-
NULL_OBJECT.error ("CLIST_ITERATOR::exchange", ABORT, NULL);
391358
if (!list)
392359
NO_LIST.error ("CLIST_ITERATOR::exchange", ABORT, NULL);
393360
if (!other_it)
@@ -490,8 +457,6 @@ CLIST_LINK *CLIST_ITERATOR::extract_sublist( //from
490457
const ERRCODE DONT_EXTRACT_DELETED =
491458
"Can't extract a sublist marked by deleted points";
492459

493-
if (!this)
494-
NULL_OBJECT.error ("CLIST_ITERATOR::extract_sublist", ABORT, NULL);
495460
if (!other_it)
496461
BAD_PARAMETER.error ("CLIST_ITERATOR::extract_sublist", ABORT,
497462
"other_it NULL");

ccutil/clst.h

-32
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ class DLLSYM CLIST_ITERATOR
255255
inline void CLIST_ITERATOR::set_to_list( //change list
256256
CLIST *list_to_iterate) {
257257
#ifndef NDEBUG
258-
if (!this)
259-
NULL_OBJECT.error ("CLIST_ITERATOR::set_to_list", ABORT, NULL);
260258
if (!list_to_iterate)
261259
BAD_PARAMETER.error ("CLIST_ITERATOR::set_to_list", ABORT,
262260
"list_to_iterate is NULL");
@@ -296,8 +294,6 @@ inline void CLIST_ITERATOR::add_after_then_move( // element to add
296294
CLIST_LINK *new_element;
297295

298296
#ifndef NDEBUG
299-
if (!this)
300-
NULL_OBJECT.error ("CLIST_ITERATOR::add_after_then_move", ABORT, NULL);
301297
if (!list)
302298
NO_LIST.error ("CLIST_ITERATOR::add_after_then_move", ABORT, NULL);
303299
if (!new_data)
@@ -346,8 +342,6 @@ inline void CLIST_ITERATOR::add_after_stay_put( // element to add
346342
CLIST_LINK *new_element;
347343

348344
#ifndef NDEBUG
349-
if (!this)
350-
NULL_OBJECT.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, NULL);
351345
if (!list)
352346
NO_LIST.error ("CLIST_ITERATOR::add_after_stay_put", ABORT, NULL);
353347
if (!new_data)
@@ -399,8 +393,6 @@ inline void CLIST_ITERATOR::add_before_then_move( // element to add
399393
CLIST_LINK *new_element;
400394

401395
#ifndef NDEBUG
402-
if (!this)
403-
NULL_OBJECT.error ("CLIST_ITERATOR::add_before_then_move", ABORT, NULL);
404396
if (!list)
405397
NO_LIST.error ("CLIST_ITERATOR::add_before_then_move", ABORT, NULL);
406398
if (!new_data)
@@ -446,8 +438,6 @@ inline void CLIST_ITERATOR::add_before_stay_put( // element to add
446438
CLIST_LINK *new_element;
447439

448440
#ifndef NDEBUG
449-
if (!this)
450-
NULL_OBJECT.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, NULL);
451441
if (!list)
452442
NO_LIST.error ("CLIST_ITERATOR::add_before_stay_put", ABORT, NULL);
453443
if (!new_data)
@@ -491,8 +481,6 @@ inline void CLIST_ITERATOR::add_before_stay_put( // element to add
491481

492482
inline void CLIST_ITERATOR::add_list_after(CLIST *list_to_add) {
493483
#ifndef NDEBUG
494-
if (!this)
495-
NULL_OBJECT.error ("CLIST_ITERATOR::add_list_after", ABORT, NULL);
496484
if (!list)
497485
NO_LIST.error ("CLIST_ITERATOR::add_list_after", ABORT, NULL);
498486
if (!list_to_add)
@@ -541,8 +529,6 @@ inline void CLIST_ITERATOR::add_list_after(CLIST *list_to_add) {
541529

542530
inline void CLIST_ITERATOR::add_list_before(CLIST *list_to_add) {
543531
#ifndef NDEBUG
544-
if (!this)
545-
NULL_OBJECT.error ("CLIST_ITERATOR::add_list_before", ABORT, NULL);
546532
if (!list)
547533
NO_LIST.error ("CLIST_ITERATOR::add_list_before", ABORT, NULL);
548534
if (!list_to_add)
@@ -591,8 +577,6 @@ inline void *CLIST_ITERATOR::extract() {
591577
void *extracted_data;
592578

593579
#ifndef NDEBUG
594-
if (!this)
595-
NULL_OBJECT.error ("CLIST_ITERATOR::extract", ABORT, NULL);
596580
if (!list)
597581
NO_LIST.error ("CLIST_ITERATOR::extract", ABORT, NULL);
598582
if (!current) //list empty or
@@ -632,8 +616,6 @@ inline void *CLIST_ITERATOR::extract() {
632616

633617
inline void *CLIST_ITERATOR::move_to_first() {
634618
#ifndef NDEBUG
635-
if (!this)
636-
NULL_OBJECT.error ("CLIST_ITERATOR::move_to_first", ABORT, NULL);
637619
if (!list)
638620
NO_LIST.error ("CLIST_ITERATOR::move_to_first", ABORT, NULL);
639621
#endif
@@ -658,8 +640,6 @@ inline void *CLIST_ITERATOR::move_to_first() {
658640

659641
inline void CLIST_ITERATOR::mark_cycle_pt() {
660642
#ifndef NDEBUG
661-
if (!this)
662-
NULL_OBJECT.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
663643
if (!list)
664644
NO_LIST.error ("CLIST_ITERATOR::mark_cycle_pt", ABORT, NULL);
665645
#endif
@@ -681,8 +661,6 @@ inline void CLIST_ITERATOR::mark_cycle_pt() {
681661

682662
inline BOOL8 CLIST_ITERATOR::at_first() {
683663
#ifndef NDEBUG
684-
if (!this)
685-
NULL_OBJECT.error ("CLIST_ITERATOR::at_first", ABORT, NULL);
686664
if (!list)
687665
NO_LIST.error ("CLIST_ITERATOR::at_first", ABORT, NULL);
688666
#endif
@@ -703,8 +681,6 @@ inline BOOL8 CLIST_ITERATOR::at_first() {
703681

704682
inline BOOL8 CLIST_ITERATOR::at_last() {
705683
#ifndef NDEBUG
706-
if (!this)
707-
NULL_OBJECT.error ("CLIST_ITERATOR::at_last", ABORT, NULL);
708684
if (!list)
709685
NO_LIST.error ("CLIST_ITERATOR::at_last", ABORT, NULL);
710686
#endif
@@ -725,8 +701,6 @@ inline BOOL8 CLIST_ITERATOR::at_last() {
725701

726702
inline BOOL8 CLIST_ITERATOR::cycled_list() {
727703
#ifndef NDEBUG
728-
if (!this)
729-
NULL_OBJECT.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);
730704
if (!list)
731705
NO_LIST.error ("CLIST_ITERATOR::cycled_list", ABORT, NULL);
732706
#endif
@@ -745,8 +719,6 @@ inline BOOL8 CLIST_ITERATOR::cycled_list() {
745719

746720
inline inT32 CLIST_ITERATOR::length() {
747721
#ifndef NDEBUG
748-
if (!this)
749-
NULL_OBJECT.error ("CLIST_ITERATOR::length", ABORT, NULL);
750722
if (!list)
751723
NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL);
752724
#endif
@@ -767,8 +739,6 @@ CLIST_ITERATOR::sort ( //sort elements
767739
int comparator ( //comparison routine
768740
const void *, const void *)) {
769741
#ifndef NDEBUG
770-
if (!this)
771-
NULL_OBJECT.error ("CLIST_ITERATOR::sort", ABORT, NULL);
772742
if (!list)
773743
NO_LIST.error ("CLIST_ITERATOR::sort", ABORT, NULL);
774744
#endif
@@ -793,8 +763,6 @@ inline void CLIST_ITERATOR::add_to_end( // element to add
793763
CLIST_LINK *new_element;
794764

795765
#ifndef NDEBUG
796-
if (!this)
797-
NULL_OBJECT.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);
798766
if (!list)
799767
NO_LIST.error ("CLIST_ITERATOR::add_to_end", ABORT, NULL);
800768
if (!new_data)

ccutil/elst.cpp

-30
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ void (*zapper) (ELIST_LINK *)) {
4444
ELIST_LINK *ptr;
4545
ELIST_LINK *next;
4646

47-
#ifndef NDEBUG
48-
if (!this)
49-
NULL_OBJECT.error ("ELIST::internal_clear", ABORT, NULL);
50-
#endif
51-
5247
if (!empty ()) {
5348
ptr = last->next; //set to first
5449
last->next = NULL; //break circle
@@ -80,11 +75,6 @@ void ELIST::assign_to_sublist( //to this list
8075
const ERRCODE LIST_NOT_EMPTY =
8176
"Destination list must be empty before extracting a sublist";
8277

83-
#ifndef NDEBUG
84-
if (!this)
85-
NULL_OBJECT.error ("ELIST::assign_to_sublist", ABORT, NULL);
86-
#endif
87-
8878
if (!empty ())
8979
LIST_NOT_EMPTY.error ("ELIST.assign_to_sublist", ABORT, NULL);
9080

@@ -102,11 +92,6 @@ inT32 ELIST::length() const { // count elements
10292
ELIST_ITERATOR it(const_cast<ELIST*>(this));
10393
inT32 count = 0;
10494

105-
#ifndef NDEBUG
106-
if (!this)
107-
NULL_OBJECT.error ("ELIST::length", ABORT, NULL);
108-
#endif
109-
11095
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
11196
count++;
11297
return count;
@@ -131,11 +116,6 @@ const void *, const void *)) {
131116
ELIST_LINK **current;
132117
inT32 i;
133118

134-
#ifndef NDEBUG
135-
if (!this)
136-
NULL_OBJECT.error ("ELIST::sort", ABORT, NULL);
137-
#endif
138-
139119
/* Allocate an array of pointers, one per list element */
140120
count = length ();
141121
base = (ELIST_LINK **) malloc (count * sizeof (ELIST_LINK *));
@@ -215,8 +195,6 @@ ELIST_LINK *ELIST::add_sorted_and_find(
215195

216196
ELIST_LINK *ELIST_ITERATOR::forward() {
217197
#ifndef NDEBUG
218-
if (!this)
219-
NULL_OBJECT.error ("ELIST_ITERATOR::forward", ABORT, NULL);
220198
if (!list)
221199
NO_LIST.error ("ELIST_ITERATOR::forward", ABORT, NULL);
222200
#endif
@@ -260,8 +238,6 @@ ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ...
260238
ELIST_LINK *ptr;
261239

262240
#ifndef NDEBUG
263-
if (!this)
264-
NULL_OBJECT.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
265241
if (!list)
266242
NO_LIST.error ("ELIST_ITERATOR::data_relative", ABORT, NULL);
267243
if (list->empty ())
@@ -295,8 +271,6 @@ ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ...
295271

296272
ELIST_LINK *ELIST_ITERATOR::move_to_last() {
297273
#ifndef NDEBUG
298-
if (!this)
299-
NULL_OBJECT.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL);
300274
if (!list)
301275
NO_LIST.error ("ELIST_ITERATOR::move_to_last", ABORT, NULL);
302276
#endif
@@ -326,8 +300,6 @@ void ELIST_ITERATOR::exchange( //positions of 2 link
326300
ELIST_LINK *old_current;
327301

328302
#ifndef NDEBUG
329-
if (!this)
330-
NULL_OBJECT.error ("ELIST_ITERATOR::exchange", ABORT, NULL);
331303
if (!list)
332304
NO_LIST.error ("ELIST_ITERATOR::exchange", ABORT, NULL);
333305
if (!other_it)
@@ -432,8 +404,6 @@ ELIST_LINK *ELIST_ITERATOR::extract_sublist( //from
432404
ELIST_LINK *end_of_new_list;
433405

434406
#ifndef NDEBUG
435-
if (!this)
436-
NULL_OBJECT.error ("ELIST_ITERATOR::extract_sublist", ABORT, NULL);
437407
if (!other_it)
438408
BAD_PARAMETER.error ("ELIST_ITERATOR::extract_sublist", ABORT,
439409
"other_it NULL");

0 commit comments

Comments
 (0)