# uxTaskGetStackHighWaterMark return type

**URL:** <https://forums.freertos.org/t/uxtaskgetstackhighwatermark-return-type/4853>\
**Category:** Kernel\
**Created:** [June 5, 2012, 6:01pm UTC](https://forums.freertos.org/t/uxtaskgetstackhighwatermark-return-type/4853 "2012-06-05T18:01:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 5, 2012, 6:01pm UTC](https://forums.freertos.org/t/uxtaskgetstackhighwatermark-return-type/4853/1 "2012-06-05T18:01:32Z")

</div>

**[tpham3783](https://sourceforge.net/u/tpham3783/)** wrote on [Tuesday, June 05, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/d447501a/#a38f):

Hi, i am running freertos an a 8bit xmega processor.&nbsp; I am trying to find the size of the unused stack space by using call to uxTaskGetStackHighWaterMark.&nbsp; However, uxTaskGetStackHighWaterMark returns portBASE\_TYPE which is defined as unsigned char in portmacro.h.&nbsp; This is not good, for example if the total unused space is more than 255, calls to uxTaskGetStackHighWaterMark is subjected to rollover, and is inaccurate.&nbsp;

I looked further into uxTaskGetStackHighWaterMark and it makes another call to check unused stack size, which returns unsigned short, but get casted to port\_BASE\_TYPE in uxTaskGetStackHighWaterMark.&nbsp; Would it be better if uxTaskGetStackHighWaterMark returns unsigned short instead?

thanks

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [June 5, 2012, 7:42pm UTC](https://forums.freertos.org/t/uxtaskgetstackhighwatermark-return-type/4853/2 "2012-06-05T19:42:45Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, June 05, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/d447501a/#c5bd):

Yes - my bad - there is a change request on exactly that point already but I have not implemented it yet.&nbsp; For now, it is easy enough to edit the source code so a size\_t is returned instead, but long term you don’t want to be editing anything in the source code (maintenance nightmare when FreeRTOS changes) so I really need to do this in the main line.&nbsp; Apologies for not doing so already.

Regards.
