Inattention
V653 A suspicious string consisting of two parts is used for array initialization. It is possible that a comma is missing. Consider inspecting this literal: “30min” “No timeout”. lp8788-charger.c 657
static ssize_t lp8788_show_eoc_time(struct device *dev, struct device_attribute *attr, char *buf) { struct lp8788_charger *pchg = dev_get_drvdata(dev); char *stime[] = { "400ms", "5min", "10min", "15min", "20min", "25min", "30min" "No timeout" }; .... }
As is known, the two consecutive literals get linked. This allows them to be used easily in macros for instance. The danger appears when we write an array of such literals: you can miss a comma, and get an unexpected result.
In this case two last literals will “stick” to each other, and we will get “30minNo timeout”. It’s a double error. Firstly, the text is incorrect; secondly, the array will be missing one element, which can lead to access out of bounds.
It makes sense to use another method of formatting, so that this error will become more evident:
char *stime[] = { "400ms" , "5min" , "10min" , "15min" , "20min" , "25min" , "30min" "No timeout" };
Please click here to see more bugs from this project.