Simplify code
The static analyzer is concerned about the strcpys below this, since it apparently doesn't try to model snprintf's potential behaviors. (In particular, it was concerned that suffixLen might be >= sizeof(suffixBuf)). While that's clearly suboptimal, this code can also be simplified to make it more obvious what's happening and to appease the analyzer. No functionality change is intended. Bug: None Test: Ran the analyzer. It's no longer angry about strcpy overflows. Change-Id: I4aa812144c90f6d3e833bbcb23c0694476a0e53e
This commit is contained in:
parent
48cf760bea
commit
487de27345
|
@ -1632,8 +1632,10 @@ LIBLOG_ABI_PUBLIC char* android_log_formatLogLine(AndroidLogFormat* p_format,
|
|||
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[38;5;%dm",
|
||||
colorFromPri(entry->priority));
|
||||
prefixLen = MIN(prefixLen, sizeof(prefixBuf));
|
||||
suffixLen = snprintf(suffixBuf, sizeof(suffixBuf), "\x1B[0m");
|
||||
suffixLen = MIN(suffixLen, sizeof(suffixBuf));
|
||||
|
||||
const char suffixContents[] = "\x1B[0m";
|
||||
strcpy(suffixBuf, suffixContents);
|
||||
suffixLen = strlen(suffixContents);
|
||||
}
|
||||
|
||||
char uid[16];
|
||||
|
|
Loading…
Reference in New Issue