Skip to content

Commit

Permalink
Fix: Codacy, pf_map cast and copy cm_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
NIKEA-SOFT authored and lmoureaux committed May 9, 2022
1 parent 3c1b68e commit 65cd09c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/aicore/cm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ bool operator==(const struct cm_parameter &p1, const struct cm_parameter &p2)
void cm_copy_parameter(struct cm_parameter *dest,
const struct cm_parameter *const src)
{
memcpy(dest, src, sizeof(struct cm_parameter));
*dest = *src;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions common/aicore/cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ struct cm_parameter {

int factor[O_LAST];
int happy_factor;

/**
* @brief Copy assignment operator
* @param other Object being copied
* @return Reference to *this
*/
cm_parameter &operator=(const cm_parameter &other) = default;
};

// A result which can examined.
Expand Down
18 changes: 16 additions & 2 deletions common/aicore/path_finding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,22 @@ struct pf_map {
struct pf_parameter params; // Initial parameters.
};

// Down-cast macro.
#define PF_MAP(pfm) ((struct pf_map *) (pfm))
/**
* Casts to `pf_map`
*
* \fixme Capitalized because this used to be a macro.
*/
pf_map *PF_MAP(void *x) { return reinterpret_cast<pf_map *>(x); }

/**
* Casts to `pf_map`
*
* \fixme Capitalized because this used to be a macro.
*/
const pf_map *PF_MAP(const void *x)
{
return reinterpret_cast<const pf_map *>(x);
}

// ========================== Common functions ===========================

Expand Down

0 comments on commit 65cd09c

Please sign in to comment.