Skip to content

Commit 53db13b

Browse files
authored
Merge pull request #58 from zhang-rui/main
fixes and improvements
2 parents b8d3cf1 + bcf8c55 commit 53db13b

File tree

7 files changed

+14
-6
lines changed

7 files changed

+14
-6
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ sbin_PROGRAMS = intel_lpmd
2626

2727
intel_lpmd_CPPFLAGS = \
2828
-I@top_srcdir@/src \
29+
-I@top_srcdir@/src/include \
2930
-DTDLOCALEDIR=\"$(datadir)/locale\" \
3031
-DGLIB_SUPPORT
3132

data/intel_lpmd.service.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
[Unit]
22
Description= Intel Linux Energy Optimizer (lpmd) Service
33
ConditionVirtualization=no
4+
StartLimitInterval=200
5+
StartLimitBurst=5
46

57
[Service]
68
Type=dbus
79
SuccessExitStatus=2
810
BusName=org.freedesktop.intel_lpmd
911
ExecStart=@sbindir@/intel_lpmd --systemd --dbus-enable
1012
Restart=on-failure
13+
RestartSec=30
1114

1215
[Install]
1316
WantedBy=multi-user.target
File renamed without changes.
File renamed without changes.

src/lpmd_config.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static void lpmd_parse_state(xmlDoc *doc, xmlNode *a_node, lpmd_config_state_t *
143143
else
144144
snprintf (state->active_cpus, sizeof(state->active_cpus), "%s", tmp_value);
145145
}
146+
xmlFree(tmp_value);
146147
}
147148
}
148149
}
@@ -196,6 +197,9 @@ static void lpmd_parse_states(xmlDoc *doc, xmlNode *a_node, lpmd_config_t *lpmd_
196197
cpu_config[MAX_CONFIG_LEN - 1] = '\0';
197198
}
198199

200+
if (tmp_value)
201+
xmlFree (tmp_value);
202+
199203
if (strncmp ((const char*) cur_node->name, "State", strlen ("State")))
200204
continue;
201205

@@ -238,14 +242,14 @@ static int lpmd_fill_config(xmlDoc *doc, xmlNode *a_node, lpmd_config_t *lpmd_co
238242
|| lpmd_config->mode < 0)
239243
goto err;
240244
}
241-
else if (!strncmp((const char*)cur_node->name, "HfiLpmEnable", strlen("HfiEnable"))) {
245+
else if (!strncmp((const char*)cur_node->name, "HfiLpmEnable", strlen("HfiLpmEnable"))) {
242246
errno = 0;
243247
lpmd_config->hfi_lpm_enable = strtol (tmp_value, &pos, 10);
244248
if (errno || *pos != '\0'
245249
|| (lpmd_config->hfi_lpm_enable != 1 && lpmd_config->hfi_lpm_enable != 0))
246250
goto err;
247251
}
248-
else if (!strncmp((const char*)cur_node->name, "HfiSuvEnable", strlen("HfiEnable"))) {
252+
else if (!strncmp((const char*)cur_node->name, "HfiSuvEnable", strlen("HfiSuvEnable"))) {
249253
errno = 0;
250254
lpmd_config->hfi_suv_enable = strtol (tmp_value, &pos, 10);
251255
if (errno || *pos != '\0'

src/lpmd_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ int init_epp_epb(void)
622622
int ret;
623623
char path[MAX_STR_LENGTH];
624624

625-
saved_cpu_info = malloc (sizeof(struct cpu_info) * max_cpus);
625+
saved_cpu_info = calloc (sizeof(struct cpu_info), max_cpus);
626626

627627
for (c = 0; c < max_cpus; c++) {
628628
saved_cpu_info[c].epp_str[0] = '\0';

src/lpmd_util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ static int enter_state(lpmd_config_state_t *state, int bsys, int bcpu)
400400

401401
static int process_next_config_state(lpmd_config_t *config, int wlt_index)
402402
{
403-
lpmd_config_state_t *state;
404-
int i;
403+
lpmd_config_state_t *state = NULL;
404+
int i = 0;
405405
int interval = -1;
406406
int epp, epb;
407-
char epp_str[32];
407+
char epp_str[32] = "";
408408

409409
// Check for new state
410410
for (i = 0; i < config->config_state_count; ++i) {

0 commit comments

Comments
 (0)