Skip to content

Commit

Permalink
Reduce to one snprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
precla committed Feb 21, 2019
1 parent 792ac8a commit aa891ab
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/intel_undervolt.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,14 @@ short applyValues(int *newValues, int *currentValues) {

int measurePowerConsumption(char currPVals[][BUFSZSMALL], powercap_list_t *pcapList, int elCount, int maxname) {
int i = 0;
char tmp[BUFSZSMALL];
powercap_list_t *pListNext = pcapList;

savePowercapNextAsDouble(pcapList, maxname);

while (pListNext) {
if (i < elCount) {
strcpy(tmp, "");
snprintf(tmp, BUFSZSMALL/2, "%s : ", pListNext->name);
strncpy(currPVals[i], tmp, BUFSZSMALL/2);
snprintf(tmp, BUFSZSMALL/2, "%3.03f W", pListNext->val);
strncat(currPVals[i], tmp, BUFSZSMALL/2);
i++;
snprintf(currPVals[i], BUFSZSMALL, "%s : %3.03f W", pListNext->name, pListNext->val);
++i;
} else {
break;
}
Expand Down

0 comments on commit aa891ab

Please sign in to comment.