btstack_util.c (43bdd57606b8830fe4caa237f0e3501ffe277d8c) | btstack_util.c (c46e8f558eefdd5a693ea66a0f0d1e8ddcbdee2c) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 660 unchanged lines hidden (view full) --- 669uint16_t btstack_snprintf_assert_complete(char * buffer, size_t size, const char * format, ...){ 670 va_list argptr; 671 va_start(argptr, format); 672 int len = vsnprintf(buffer, size, format, argptr); 673 va_end(argptr); 674 675 // check for no error and no truncation 676 btstack_assert(len >= 0); | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 660 unchanged lines hidden (view full) --- 669uint16_t btstack_snprintf_assert_complete(char * buffer, size_t size, const char * format, ...){ 670 va_list argptr; 671 va_start(argptr, format); 672 int len = vsnprintf(buffer, size, format, argptr); 673 va_end(argptr); 674 675 // check for no error and no truncation 676 btstack_assert(len >= 0); |
677 btstack_assert(len < size); | 677 btstack_assert((unsigned int) len < size); |
678 return (uint16_t) len; 679} 680 681uint16_t btstack_snprintf_best_effort(char * buffer, size_t size, const char * format, ...){ 682 btstack_assert(size > 0); 683 va_list argptr; 684 va_start(argptr, format); 685 int len = vsnprintf(buffer, size, format, argptr); --- 44 unchanged lines hidden --- | 678 return (uint16_t) len; 679} 680 681uint16_t btstack_snprintf_best_effort(char * buffer, size_t size, const char * format, ...){ 682 btstack_assert(size > 0); 683 va_list argptr; 684 va_start(argptr, format); 685 int len = vsnprintf(buffer, size, format, argptr); --- 44 unchanged lines hidden --- |