crayzeewulf / libserial

Serial Port Programming in C++
BSD 3-Clause "New" or "Revised" License
415 stars 142 forks source link

SerialPort.cpp: fix build when size_t is an unsigned int #126

Closed ffontaine closed 5 years ago

ffontaine commented 5 years ago

size_t can be defined as an unsigned int instead of long unsigned int so replace 1UL to (size_t)1 when calling max function

Signed-off-by: Fabrice Fontaine fontaine.fabrice@gmail.com

mcsauder commented 5 years ago

Nice catch @ffontaine!

@crayzeewulf , this looks great to me, hardware unit tests all pass with this PR. Good to go!

-Mark

mcsauder commented 5 years ago

For the convenience of anyone else who might be curious, https://en.cppreference.com/w/cpp/types/size_t http://www.cplusplus.com/reference/cstring/size_t/ Thanks again for the PR @ffontaine .

crayzeewulf commented 5 years ago

Fabrice:

Thanks for suggestion. Libserial avoids use of C-style casts in the code. How about using static cast instead. In other words:

static_cast<size_t>(1)

or just:

size_t {1}

Otherwise, it looks like a valid update.

crayzeewulf commented 5 years ago

Here is a useful/relevant article from Scott Meyers on this subject for reference.

crayzeewulf commented 5 years ago

Nice catch @ffontaine!

@crayzeewulf , this looks great to me, hardware unit tests all pass with this PR. Good to go!

-Mark

Thanks for checking this, Mark. Other than my nitpick about C-style casts, it ought to be good to make this change.

ffontaine commented 5 years ago

Indeed, size_t {1} is also ok, I will update the PR.

crayzeewulf commented 5 years ago

Indeed, size_t {1} is also ok, I will update the PR.

Thanks!!!