mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: remove snprintf use to fix MISRA 17.1
MISRA rule 17.1 forbids use of stdarg.h features defined for variable arguments. This patch modifies functions using snprintf() to use standard library string functions. Jira NVGPU-4075 Change-Id: I206cb812fc46e9f463e4b7f392fa4f0e388d5706 Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2211270 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Philip Elcan <pelcan@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
8c8965396e
commit
e56a9186b1
@@ -364,53 +364,6 @@
|
||||
*/
|
||||
#define MHZ_TO_HZ_ULL(a) ((u64)(a) * MHZ)
|
||||
|
||||
/*
|
||||
* Caps return at the size of the buffer not what would have been written if buf
|
||||
* were arbitrarily sized.
|
||||
*/
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
/**
|
||||
* @brief Format a string and store it in buffer.
|
||||
*
|
||||
* @param buf [in,out] Buffer to hold the formatted string.
|
||||
* @param size [in] Size of the buf.
|
||||
* @param format [in] Format of the input string.
|
||||
* @param args [in] Variable length args.
|
||||
*
|
||||
* Formats the string and places it in the location referenced by input
|
||||
* parameter buf.
|
||||
*
|
||||
* @return Returns the number of characters printed in a successful scenario,
|
||||
* Otherwise returns the error code.
|
||||
*/
|
||||
static inline int scnprintf(char *buf, size_t size, const char *format, ...)
|
||||
{
|
||||
size_t ret;
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
ret = (size_t)vsnprintf(buf, size, format, args);
|
||||
va_end(args);
|
||||
|
||||
return ret <= size ? (int)ret : (int)size;
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief Dummy function for scnprintf if logging is disabled.
|
||||
*
|
||||
* @param buf [in,out] Buffer to hold the formatted string.
|
||||
* @param size [in] Size of the buf.
|
||||
* @param format [in] Format of the input string.
|
||||
* @param args [in] Variable length args.
|
||||
*
|
||||
* @return Returns 0.
|
||||
*/
|
||||
static inline int scnprintf(char *buf, size_t size, const char *format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Endian conversion.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user