Caution.. bug in app_util.h ALIGN_NUM function when data type is not unsigned int / uint32_t

I learned today that the ALIGN_NUM macro doesn't work as expected if the data type passed is not unsigned int type.  I find that using int32_t or uint8_t with ALIGN_NUM produces unexpected values at 0.  

I was able to fix the behavior with a small change to the macro, making the 1  an unsigned type 1ul

Here is the original macro

/**@brief Macro for increasing a number to the nearest (larger) multiple of another number.
*
* @param[in] alignment The number to align to.
* @param[in] number The number to align (increase).
*
* @return The aligned (increased) @p number.
*/
#define ALIGN_NUM(alignment, number) (((number) - 1) + (alignment) - (((number) - 1) % (alignment)))

Here is a macro that I confirmed works for addresses, uint32_t, int32_t and uint8_t. 

/**@brief Macro for increasing a number to the nearest (larger) multiple of another number.
*
* @param[in] alignment The number to align to.
* @param[in] number The number to align (increase).
*
* @return The aligned (increased) @p number.
*/
#define ALIGN_NUM(alignment, number) (((number) - 1ul) + (alignment) - (((number) - 1ul) % (alignment)))

Related