Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 8b51a6bf5a4829d8add535a098c0c06a049a9958 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 26 Aug 2017 22:50:57 -0700 |
| 4 | Subject: [PATCH] lanserv: Rename struct parameter printf for namespace |
| 5 | collision |
| 6 | |
| 7 | This comes to fore when we use hardening flags where printf |
| 8 | is treated as macro and gets replaced with printf_chk |
| 9 | |
| 10 | Fixes errors like |
| 11 | |
| 12 | error: no member named '__printf_chk' in 'struct emu_out_s' |
| 13 | |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | lanserv/OpenIPMI/serv.h | 2 +- |
| 17 | lanserv/emu_cmd.c | 132 ++++++++++++++++++++++++------------------------ |
| 18 | lanserv/ipmi_sim.c | 10 ++-- |
| 19 | 3 files changed, 72 insertions(+), 72 deletions(-) |
| 20 | |
| 21 | diff --git a/lanserv/OpenIPMI/serv.h b/lanserv/OpenIPMI/serv.h |
| 22 | index d12d63a..8555c85 100644 |
| 23 | --- a/lanserv/OpenIPMI/serv.h |
| 24 | +++ b/lanserv/OpenIPMI/serv.h |
| 25 | @@ -522,7 +522,7 @@ uint8_t ipmb_checksum(uint8_t *data, int size, uint8_t start); |
| 26 | typedef struct emu_data_s emu_data_t; |
| 27 | typedef struct emu_out_s |
| 28 | { |
| 29 | - void (*printf)(struct emu_out_s *out, char *format, ...); |
| 30 | + void (*eprintf)(struct emu_out_s *out, char *format, ...); |
| 31 | void *data; |
| 32 | } emu_out_t; |
| 33 | |
| 34 | diff --git a/lanserv/emu_cmd.c b/lanserv/emu_cmd.c |
| 35 | index ca44032..54b6f7b 100644 |
| 36 | --- a/lanserv/emu_cmd.c |
| 37 | +++ b/lanserv/emu_cmd.c |
| 38 | @@ -76,7 +76,7 @@ emu_get_uchar(emu_out_t *out, char **toks, unsigned char *val, char *errstr, |
| 39 | if (empty_ok) |
| 40 | return ENOSPC; |
| 41 | if (errstr) |
| 42 | - out->printf(out, "**No %s given\n", errstr); |
| 43 | + out->eprintf(out, "**No %s given\n", errstr); |
| 44 | return EINVAL; |
| 45 | } |
| 46 | if (str[0] == '\'') { |
| 47 | @@ -86,7 +86,7 @@ emu_get_uchar(emu_out_t *out, char **toks, unsigned char *val, char *errstr, |
| 48 | *val = strtoul(str, &tmpstr, 0); |
| 49 | if (*tmpstr != '\0') { |
| 50 | if (errstr) |
| 51 | - out->printf(out, "**Invalid %s given\n", errstr); |
| 52 | + out->eprintf(out, "**Invalid %s given\n", errstr); |
| 53 | return EINVAL; |
| 54 | } |
| 55 | |
| 56 | @@ -108,7 +108,7 @@ emu_get_uchar_with_vals(emu_out_t *out, char **toks, |
| 57 | if (empty_ok) |
| 58 | return ENOSPC; |
| 59 | if (errstr) |
| 60 | - out->printf(out, "**No %s given\n", errstr); |
| 61 | + out->eprintf(out, "**No %s given\n", errstr); |
| 62 | return EINVAL; |
| 63 | } |
| 64 | if (str[0] == '\'') { |
| 65 | @@ -131,7 +131,7 @@ emu_get_uchar_with_vals(emu_out_t *out, char **toks, |
| 66 | *val = strtoul(str, &tmpstr, 0); |
| 67 | if (*tmpstr != '\0') { |
| 68 | if (errstr) |
| 69 | - out->printf(out, "**Invalid %s given\n", errstr); |
| 70 | + out->eprintf(out, "**Invalid %s given\n", errstr); |
| 71 | return EINVAL; |
| 72 | } |
| 73 | out: |
| 74 | @@ -150,12 +150,12 @@ emu_get_bitmask(emu_out_t *out, char **toks, uint16_t *val, char *errstr, |
| 75 | if (empty_ok) |
| 76 | return ENOSPC; |
| 77 | if (errstr) |
| 78 | - out->printf(out, "**No %s given\n", errstr); |
| 79 | + out->eprintf(out, "**No %s given\n", errstr); |
| 80 | return EINVAL; |
| 81 | } |
| 82 | if (strlen(str) != size) { |
| 83 | if (errstr) |
| 84 | - out->printf(out, "**invalid number of bits in %s\n", errstr); |
| 85 | + out->eprintf(out, "**invalid number of bits in %s\n", errstr); |
| 86 | return EINVAL; |
| 87 | } |
| 88 | *val = 0; |
| 89 | @@ -166,7 +166,7 @@ emu_get_bitmask(emu_out_t *out, char **toks, uint16_t *val, char *errstr, |
| 90 | *val |= 1 << i; |
| 91 | } else { |
| 92 | if (errstr) |
| 93 | - out->printf(out, "**Invalid bit value '%c' in %s\n", str[j], |
| 94 | + out->eprintf(out, "**Invalid bit value '%c' in %s\n", str[j], |
| 95 | errstr); |
| 96 | return EINVAL; |
| 97 | } |
| 98 | @@ -184,13 +184,13 @@ emu_get_uint(emu_out_t *out, char **toks, unsigned int *val, char *errstr) |
| 99 | str = mystrtok(NULL, " \t\n", toks); |
| 100 | if (!str) { |
| 101 | if (errstr) |
| 102 | - out->printf(out, "**No %s given\n", errstr); |
| 103 | + out->eprintf(out, "**No %s given\n", errstr); |
| 104 | return EINVAL; |
| 105 | } |
| 106 | *val = strtoul(str, &tmpstr, 0); |
| 107 | if (*tmpstr != '\0') { |
| 108 | if (errstr) |
| 109 | - out->printf(out, "**Invalid %s given\n", errstr); |
| 110 | + out->eprintf(out, "**Invalid %s given\n", errstr); |
| 111 | return EINVAL; |
| 112 | } |
| 113 | |
| 114 | @@ -206,7 +206,7 @@ emu_get_bytes(emu_out_t *out, char **tokptr, unsigned char *data, char *errstr, |
| 115 | |
| 116 | if (!tok) { |
| 117 | if (errstr) |
| 118 | - out->printf(out, "**No %s given\n", errstr); |
| 119 | + out->eprintf(out, "**No %s given\n", errstr); |
| 120 | return EINVAL; |
| 121 | } |
| 122 | if (*tok == '"') { |
| 123 | @@ -215,7 +215,7 @@ emu_get_bytes(emu_out_t *out, char **tokptr, unsigned char *data, char *errstr, |
| 124 | tok++; |
| 125 | end = strlen(tok) - 1; |
| 126 | if (tok[end] != '"') { |
| 127 | - out->printf(out, "**ASCII %s doesn't end in '\"'", errstr); |
| 128 | + out->eprintf(out, "**ASCII %s doesn't end in '\"'", errstr); |
| 129 | return EINVAL; |
| 130 | } |
| 131 | if (end > (len - 1)) |
| 132 | @@ -228,7 +228,7 @@ emu_get_bytes(emu_out_t *out, char **tokptr, unsigned char *data, char *errstr, |
| 133 | char c[3]; |
| 134 | /* HEX pw */ |
| 135 | if (strlen(tok) != 32) { |
| 136 | - out->printf(out, "**HEX %s not 32 HEX characters long", errstr); |
| 137 | + out->eprintf(out, "**HEX %s not 32 HEX characters long", errstr); |
| 138 | return EINVAL; |
| 139 | } |
| 140 | c[2] = '\0'; |
| 141 | @@ -239,7 +239,7 @@ emu_get_bytes(emu_out_t *out, char **tokptr, unsigned char *data, char *errstr, |
| 142 | tok++; |
| 143 | data[i] = strtoul(c, &end, 16); |
| 144 | if (*end != '\0') { |
| 145 | - out->printf(out, "**Invalid HEX character in %s", errstr); |
| 146 | + out->eprintf(out, "**Invalid HEX character in %s", errstr); |
| 147 | return -1; |
| 148 | } |
| 149 | } |
| 150 | @@ -263,12 +263,12 @@ read_command_file(emu_out_t *out, emu_data_t *emu, const char *command_file) |
| 151 | |
| 152 | buffer = malloc(INPUT_BUFFER_SIZE); |
| 153 | if (!buffer) { |
| 154 | - out->printf(out, "Could not allocate buffer memory\n"); |
| 155 | + out->eprintf(out, "Could not allocate buffer memory\n"); |
| 156 | rv = ENOMEM; |
| 157 | goto out; |
| 158 | } |
| 159 | while (fgets(buffer+pos, INPUT_BUFFER_SIZE-pos, f)) { |
| 160 | - out->printf(out, "%s", buffer+pos); |
| 161 | + out->eprintf(out, "%s", buffer+pos); |
| 162 | if (buffer[pos] == '#') |
| 163 | continue; |
| 164 | pos = strlen(buffer); |
| 165 | @@ -318,7 +318,7 @@ sel_enable(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 166 | |
| 167 | rv = ipmi_mc_enable_sel(mc, max_records, flags); |
| 168 | if (rv) |
| 169 | - out->printf(out, "**Unable to enable sel, error 0x%x\n", rv); |
| 170 | + out->eprintf(out, "**Unable to enable sel, error 0x%x\n", rv); |
| 171 | return rv; |
| 172 | } |
| 173 | |
| 174 | @@ -343,9 +343,9 @@ sel_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 175 | |
| 176 | rv = ipmi_mc_add_to_sel(mc, record_type, data, &r); |
| 177 | if (rv) |
| 178 | - out->printf(out, "**Unable to add to sel, error 0x%x\n", rv); |
| 179 | + out->eprintf(out, "**Unable to add to sel, error 0x%x\n", rv); |
| 180 | else |
| 181 | - out->printf(out, "Added record %d\n", r); |
| 182 | + out->eprintf(out, "Added record %d\n", r); |
| 183 | return rv; |
| 184 | } |
| 185 | |
| 186 | @@ -361,14 +361,14 @@ main_sdr_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 187 | if (rv == ENOSPC) |
| 188 | break; |
| 189 | if (rv) { |
| 190 | - out->printf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 191 | + out->eprintf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 192 | return rv; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | rv = ipmi_mc_add_main_sdr(mc, data, i); |
| 197 | if (rv) |
| 198 | - out->printf(out, "**Unable to add to sdr, error 0x%x\n", rv); |
| 199 | + out->eprintf(out, "**Unable to add to sdr, error 0x%x\n", rv); |
| 200 | return rv; |
| 201 | } |
| 202 | |
| 203 | @@ -389,14 +389,14 @@ device_sdr_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 204 | if (rv == ENOSPC) |
| 205 | break; |
| 206 | if (rv) { |
| 207 | - out->printf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 208 | + out->eprintf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 209 | return rv; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | rv = ipmi_mc_add_device_sdr(mc, lun, data, i); |
| 214 | if (rv) |
| 215 | - out->printf(out, "**Unable to add to sdr, error 0x%x\n", rv); |
| 216 | + out->eprintf(out, "**Unable to add to sdr, error 0x%x\n", rv); |
| 217 | return rv; |
| 218 | } |
| 219 | |
| 220 | @@ -439,7 +439,7 @@ sensor_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 221 | while (tok) { |
| 222 | if (strcmp(tok, "poll") == 0) { |
| 223 | if (handler) { |
| 224 | - out->printf(out, "**poll given twice in sensor\n", tok); |
| 225 | + out->eprintf(out, "**poll given twice in sensor\n", tok); |
| 226 | return -1; |
| 227 | } |
| 228 | |
| 229 | @@ -449,27 +449,27 @@ sensor_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 230 | |
| 231 | tok = mystrtok(NULL, " \t\n", toks); |
| 232 | if (!tok) { |
| 233 | - out->printf(out, "**No polled sensor handler given\n", tok); |
| 234 | + out->eprintf(out, "**No polled sensor handler given\n", tok); |
| 235 | return -1; |
| 236 | } |
| 237 | |
| 238 | handler = ipmi_sensor_find_handler(tok); |
| 239 | if (!handler) { |
| 240 | - out->printf(out, "**Invalid sensor handler: %s\n", tok); |
| 241 | + out->eprintf(out, "**Invalid sensor handler: %s\n", tok); |
| 242 | return -1; |
| 243 | } |
| 244 | |
| 245 | rv = handler->init(mc, lun, num, toks, handler->cb_data, &rcb_data, |
| 246 | &errstr); |
| 247 | if (rv) { |
| 248 | - out->printf(out, "**Error initializing sensor handler: %s\n", |
| 249 | + out->eprintf(out, "**Error initializing sensor handler: %s\n", |
| 250 | errstr); |
| 251 | return rv; |
| 252 | } |
| 253 | } else if (strcmp(tok, "event-only") == 0) { |
| 254 | event_only = 1; |
| 255 | } else { |
| 256 | - out->printf(out, "**Unknown sensor option: %s\n", tok); |
| 257 | + out->eprintf(out, "**Unknown sensor option: %s\n", tok); |
| 258 | return -1; |
| 259 | } |
| 260 | |
| 261 | @@ -477,7 +477,7 @@ sensor_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 262 | } |
| 263 | |
| 264 | if (handler && event_only) { |
| 265 | - out->printf(out, "**An event-only sensor cannot be polled\n"); |
| 266 | + out->eprintf(out, "**An event-only sensor cannot be polled\n"); |
| 267 | return -1; |
| 268 | } |
| 269 | |
| 270 | @@ -488,7 +488,7 @@ sensor_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 271 | if (!rv && handler->postinit) { |
| 272 | rv = handler->postinit(rcb_data, &errstr); |
| 273 | if (rv) { |
| 274 | - out->printf(out, "**Error in sensor handler postinit: %s\n", |
| 275 | + out->eprintf(out, "**Error in sensor handler postinit: %s\n", |
| 276 | errstr); |
| 277 | } |
| 278 | } |
| 279 | @@ -496,7 +496,7 @@ sensor_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 280 | rv = ipmi_mc_add_sensor(mc, lun, num, type, code, event_only); |
| 281 | } |
| 282 | if (rv) |
| 283 | - out->printf(out, "**Unable to add to sensor, error 0x%x\n", rv); |
| 284 | + out->eprintf(out, "**Unable to add to sensor, error 0x%x\n", rv); |
| 285 | return rv; |
| 286 | } |
| 287 | |
| 288 | @@ -532,7 +532,7 @@ sensor_set_bit(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 289 | |
| 290 | rv = ipmi_mc_sensor_set_bit(mc, lun, num, bit, value, gen_event); |
| 291 | if (rv) |
| 292 | - out->printf(out, "**Unable to set sensor bit, error 0x%x\n", rv); |
| 293 | + out->eprintf(out, "**Unable to set sensor bit, error 0x%x\n", rv); |
| 294 | return rv; |
| 295 | } |
| 296 | |
| 297 | @@ -563,7 +563,7 @@ sensor_set_bit_clr_rest(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char ** |
| 298 | |
| 299 | rv = ipmi_mc_sensor_set_bit_clr_rest(mc, lun, num, bit, gen_event); |
| 300 | if (rv) |
| 301 | - out->printf(out, "**Unable to set sensor bit, error 0x%x\n", rv); |
| 302 | + out->eprintf(out, "**Unable to set sensor bit, error 0x%x\n", rv); |
| 303 | return rv; |
| 304 | } |
| 305 | |
| 306 | @@ -594,7 +594,7 @@ sensor_set_value(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 307 | |
| 308 | rv = ipmi_mc_sensor_set_value(mc, lun, num, value, gen_event); |
| 309 | if (rv) |
| 310 | - out->printf(out, "**Unable to set sensor value, error 0x%x\n", rv); |
| 311 | + out->eprintf(out, "**Unable to set sensor value, error 0x%x\n", rv); |
| 312 | return rv; |
| 313 | } |
| 314 | |
| 315 | @@ -637,7 +637,7 @@ sensor_set_hysteresis(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **to |
| 316 | rv = ipmi_mc_sensor_set_hysteresis(mc, lun, num, support, positive, |
| 317 | negative); |
| 318 | if (rv) |
| 319 | - out->printf(out, "**Unable to set sensor hysteresis, error 0x%x\n", rv); |
| 320 | + out->eprintf(out, "**Unable to set sensor hysteresis, error 0x%x\n", rv); |
| 321 | return rv; |
| 322 | } |
| 323 | |
| 324 | @@ -682,7 +682,7 @@ sensor_set_threshold(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **tok |
| 325 | rv = ipmi_mc_sensor_set_threshold(mc, lun, num, support, |
| 326 | enabled, 1, thresholds); |
| 327 | if (rv) |
| 328 | - out->printf(out, "**Unable to set sensor thresholds, error 0x%x\n", rv); |
| 329 | + out->eprintf(out, "**Unable to set sensor thresholds, error 0x%x\n", rv); |
| 330 | return rv; |
| 331 | } |
| 332 | |
| 333 | @@ -759,7 +759,7 @@ sensor_set_event_support(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char * |
| 334 | assert_support, deassert_support, |
| 335 | assert_enabled, deassert_enabled); |
| 336 | if (rv) |
| 337 | - out->printf(out, "**Unable to set sensor thresholds, error 0x%x\n", rv); |
| 338 | + out->eprintf(out, "**Unable to set sensor thresholds, error 0x%x\n", rv); |
| 339 | return rv; |
| 340 | } |
| 341 | |
| 342 | @@ -819,7 +819,7 @@ mc_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 343 | else if (strcmp("persist_sdr", tok) == 0) |
| 344 | flags |= IPMI_MC_PERSIST_SDR; |
| 345 | else { |
| 346 | - out->printf(out, "**Invalid MC flag: %s\n", tok); |
| 347 | + out->eprintf(out, "**Invalid MC flag: %s\n", tok); |
| 348 | return -1; |
| 349 | } |
| 350 | } |
| 351 | @@ -833,7 +833,7 @@ mc_add(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 352 | device_revision, major_fw_rev, minor_fw_rev, |
| 353 | device_support, mfg_id, product_id, flags); |
| 354 | if (rv) |
| 355 | - out->printf(out, "**Unable to add the MC, error 0x%x\n", rv); |
| 356 | + out->eprintf(out, "**Unable to add the MC, error 0x%x\n", rv); |
| 357 | return rv; |
| 358 | } |
| 359 | |
| 360 | @@ -890,7 +890,7 @@ mc_set_power(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 361 | |
| 362 | rv = ipmi_mc_set_power(mc, power, gen_int); |
| 363 | if (rv) |
| 364 | - out->printf(out, "**Unable to set power, error 0x%x\n", rv); |
| 365 | + out->eprintf(out, "**Unable to set power, error 0x%x\n", rv); |
| 366 | return rv; |
| 367 | } |
| 368 | |
| 369 | @@ -916,7 +916,7 @@ mc_add_fru_data(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 370 | |
| 371 | tok = mystrtok(NULL, " \t\n", toks); |
| 372 | if (!tok) { |
| 373 | - out->printf(out, "**No FRU data type given"); |
| 374 | + out->eprintf(out, "**No FRU data type given"); |
| 375 | return -1; |
| 376 | } |
| 377 | if (strcmp(tok, "file") == 0) { |
| 378 | @@ -929,13 +929,13 @@ mc_add_fru_data(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 379 | |
| 380 | rv = get_delim_str(toks, &frufn, &errstr); |
| 381 | if (rv) { |
| 382 | - out->printf(out, "**Error with FRU filename: %d", strerror(rv)); |
| 383 | + out->eprintf(out, "**Error with FRU filename: %d", strerror(rv)); |
| 384 | return rv; |
| 385 | } |
| 386 | rv = ipmi_mc_add_fru_file(mc, devid, length, file_offset, |
| 387 | (void *) frufn); |
| 388 | if (rv) |
| 389 | - out->printf(out, "**Unable to add FRU file, error 0x%x\n", rv); |
| 390 | + out->eprintf(out, "**Unable to add FRU file, error 0x%x\n", rv); |
| 391 | |
| 392 | } else if (strcmp(tok, "data") == 0) { |
| 393 | for (i=0; i<length; i++) { |
| 394 | @@ -943,14 +943,14 @@ mc_add_fru_data(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 395 | if (rv == ENOSPC) |
| 396 | break; |
| 397 | if (rv) { |
| 398 | - out->printf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 399 | + out->eprintf(out, "**Error 0x%x in data byte %d\n", rv, i); |
| 400 | return rv; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | rv = emu_get_uchar(out, toks, &data[i], "data byte", 1); |
| 405 | if (rv != ENOSPC) { |
| 406 | - out->printf(out, "**Error: input data too long for FRU\n", rv, i); |
| 407 | + out->eprintf(out, "**Error: input data too long for FRU\n", rv, i); |
| 408 | return EINVAL; |
| 409 | } |
| 410 | |
| 411 | @@ -958,9 +958,9 @@ mc_add_fru_data(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 412 | |
| 413 | rv = ipmi_mc_add_fru_data(mc, devid, length, NULL, data); |
| 414 | if (rv) |
| 415 | - out->printf(out, "**Unable to add FRU data, error 0x%x\n", rv); |
| 416 | + out->eprintf(out, "**Unable to add FRU data, error 0x%x\n", rv); |
| 417 | } else { |
| 418 | - out->printf(out, "**FRU type not given, need file or data\n"); |
| 419 | + out->eprintf(out, "**FRU type not given, need file or data\n"); |
| 420 | rv = EINVAL; |
| 421 | } |
| 422 | return rv; |
| 423 | @@ -981,28 +981,28 @@ mc_dump_fru_data(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 424 | |
| 425 | rv = ipmi_mc_get_fru_data_len(mc, devid, &length); |
| 426 | if (rv) { |
| 427 | - out->printf(out, "**Unable to dump FRU data, error 0x%x\n", rv); |
| 428 | + out->eprintf(out, "**Unable to dump FRU data, error 0x%x\n", rv); |
| 429 | goto out; |
| 430 | } |
| 431 | |
| 432 | data = malloc(length); |
| 433 | if (!data) { |
| 434 | - out->printf(out, "**Unable to dump FRU data, out of memory\n", rv); |
| 435 | + out->eprintf(out, "**Unable to dump FRU data, out of memory\n", rv); |
| 436 | goto out; |
| 437 | } |
| 438 | |
| 439 | rv = ipmi_mc_get_fru_data(mc, devid, length, data); |
| 440 | if (rv) { |
| 441 | - out->printf(out, "**Unable to dump FRU data, error 0x%x\n", rv); |
| 442 | + out->eprintf(out, "**Unable to dump FRU data, error 0x%x\n", rv); |
| 443 | goto out; |
| 444 | } |
| 445 | |
| 446 | for (i=0; i<length; i++) { |
| 447 | if ((i > 0) && ((i % 8) == 0)) |
| 448 | - out->printf(out, "\n"); |
| 449 | - out->printf(out, " 0x%2.2x", data[i]); |
| 450 | + out->eprintf(out, "\n"); |
| 451 | + out->eprintf(out, " 0x%2.2x", data[i]); |
| 452 | } |
| 453 | - out->printf(out, "\n"); |
| 454 | + out->eprintf(out, "\n"); |
| 455 | |
| 456 | out: |
| 457 | if (data) |
| 458 | @@ -1021,7 +1021,7 @@ mc_setbmc(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 459 | return rv; |
| 460 | rv = ipmi_emu_set_bmc_mc(emu, ipmb); |
| 461 | if (rv) |
| 462 | - out->printf(out, "**Invalid IPMB address\n"); |
| 463 | + out->eprintf(out, "**Invalid IPMB address\n"); |
| 464 | return rv; |
| 465 | } |
| 466 | |
| 467 | @@ -1032,7 +1032,7 @@ atca_enable(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 468 | |
| 469 | rv = ipmi_emu_atca_enable(emu); |
| 470 | if (rv) |
| 471 | - out->printf(out, "**Unable to enable ATCA mode, error 0x%x\n", rv); |
| 472 | + out->eprintf(out, "**Unable to enable ATCA mode, error 0x%x\n", rv); |
| 473 | return rv; |
| 474 | } |
| 475 | |
| 476 | @@ -1056,7 +1056,7 @@ atca_set_site(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 477 | |
| 478 | rv = ipmi_emu_atca_set_site(emu, hw_address, site_type, site_number); |
| 479 | if (rv) |
| 480 | - out->printf(out, "**Unable to set site type, error 0x%x\n", rv); |
| 481 | + out->eprintf(out, "**Unable to set site type, error 0x%x\n", rv); |
| 482 | return rv; |
| 483 | } |
| 484 | |
| 485 | @@ -1072,7 +1072,7 @@ mc_set_num_leds(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 486 | |
| 487 | rv = ipmi_mc_set_num_leds(mc, count); |
| 488 | if (rv) |
| 489 | - out->printf(out, "**Unable to set number of LEDs, error 0x%x\n", rv); |
| 490 | + out->eprintf(out, "**Unable to set number of LEDs, error 0x%x\n", rv); |
| 491 | return rv; |
| 492 | } |
| 493 | |
| 494 | @@ -1085,7 +1085,7 @@ read_cmds(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 495 | |
| 496 | err = get_delim_str(toks, &filename, &errstr); |
| 497 | if (err) { |
| 498 | - out->printf(out, "Could not get include filename: %s\n", errstr); |
| 499 | + out->eprintf(out, "Could not get include filename: %s\n", errstr); |
| 500 | return err; |
| 501 | } |
| 502 | |
| 503 | @@ -1097,7 +1097,7 @@ read_cmds(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 504 | { |
| 505 | char *nf = malloc(strlen(BASE_CONF_STR) + strlen(filename) + 2); |
| 506 | if (!nf) { |
| 507 | - out->printf(out, "Out of memory in include\n", errstr); |
| 508 | + out->eprintf(out, "Out of memory in include\n", errstr); |
| 509 | goto out_err; |
| 510 | } |
| 511 | strcpy(nf, BASE_CONF_STR); |
| 512 | @@ -1107,7 +1107,7 @@ read_cmds(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 513 | filename = nf; |
| 514 | err = read_command_file(out, emu, filename); |
| 515 | if (err) { |
| 516 | - out->printf(out, "Could not read include file %s\n", filename); |
| 517 | + out->eprintf(out, "Could not read include file %s\n", filename); |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | @@ -1147,7 +1147,7 @@ debug_cmd(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 522 | } else if (strcmp(tok, "sol") == 0) { |
| 523 | level |= DEBUG_SOL; |
| 524 | } else { |
| 525 | - out->printf(out, "Invalid debug level '%s', options are 'raw' and 'msg'\n", |
| 526 | + out->eprintf(out, "Invalid debug level '%s', options are 'raw' and 'msg'\n", |
| 527 | tok); |
| 528 | return EINVAL; |
| 529 | } |
| 530 | @@ -1168,7 +1168,7 @@ persist_cmd(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 531 | } else if (strcmp(tok, "off") == 0) { |
| 532 | persist_enable = 0; |
| 533 | } else { |
| 534 | - out->printf(out, "Invalid persist vale '%s', options are 'on' and 'off'\n", |
| 535 | + out->eprintf(out, "Invalid persist vale '%s', options are 'on' and 'off'\n", |
| 536 | tok); |
| 537 | return EINVAL; |
| 538 | } |
| 539 | @@ -1194,18 +1194,18 @@ do_define(emu_out_t *out, emu_data_t *emu, lmc_data_t *mc, char **toks) |
| 540 | |
| 541 | name = mystrtok(NULL, " \t\n", toks); |
| 542 | if (!name) { |
| 543 | - out->printf(out, "No variable name given for define\n"); |
| 544 | + out->eprintf(out, "No variable name given for define\n"); |
| 545 | return EINVAL; |
| 546 | } |
| 547 | err = get_delim_str(toks, &value, &errstr); |
| 548 | if (err) { |
| 549 | - out->printf(out, "Could not get variable %s value: %s\n", name, errstr); |
| 550 | + out->eprintf(out, "Could not get variable %s value: %s\n", name, errstr); |
| 551 | return err; |
| 552 | } |
| 553 | err = add_variable(name, value); |
| 554 | if (err) { |
| 555 | free(value); |
| 556 | - out->printf(out, "Out of memory setting variable %s\n", name); |
| 557 | + out->eprintf(out, "Out of memory setting variable %s\n", name); |
| 558 | return err; |
| 559 | } |
| 560 | return 0; |
| 561 | @@ -1301,7 +1301,7 @@ ipmi_emu_cmd(emu_out_t *out, emu_data_t *emu, char *cmd_str) |
| 562 | return rv; |
| 563 | rv = ipmi_emu_get_mc_by_addr(emu, ipmb, &mc); |
| 564 | if (rv) { |
| 565 | - out->printf(out, "**Invalid MC address\n"); |
| 566 | + out->eprintf(out, "**Invalid MC address\n"); |
| 567 | return rv; |
| 568 | } |
| 569 | } |
| 570 | @@ -1312,7 +1312,7 @@ ipmi_emu_cmd(emu_out_t *out, emu_data_t *emu, char *cmd_str) |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | - out->printf(out, "**Unknown command: %s\n", cmd); |
| 575 | + out->eprintf(out, "**Unknown command: %s\n", cmd); |
| 576 | |
| 577 | out: |
| 578 | return rv; |
| 579 | diff --git a/lanserv/ipmi_sim.c b/lanserv/ipmi_sim.c |
| 580 | index 9472cce..30c4f27 100644 |
| 581 | --- a/lanserv/ipmi_sim.c |
| 582 | +++ b/lanserv/ipmi_sim.c |
| 583 | @@ -607,8 +607,8 @@ isim_log(sys_data_t *sys, int logtype, msg_t *msg, const char *format, |
| 584 | |
| 585 | con = data->consoles; |
| 586 | while (con) { |
| 587 | - con->out.printf(&con->out, "%s", str); |
| 588 | - con->out.printf(&con->out, "\n"); |
| 589 | + con->out.eprintf(&con->out, "%s", str); |
| 590 | + con->out.eprintf(&con->out, "\n"); |
| 591 | con = con->next; |
| 592 | } |
| 593 | #if HAVE_SYSLOG |
| 594 | @@ -956,7 +956,7 @@ console_bind_ready(int fd, void *cb_data, os_hnd_fd_id_t *id) |
| 595 | newcon->shutdown_on_close = 0; |
| 596 | newcon->telnet = 1; |
| 597 | newcon->tn_pos = 0; |
| 598 | - newcon->out.printf = emu_printf; |
| 599 | + newcon->out.eprintf = emu_printf; |
| 600 | newcon->out.data = newcon; |
| 601 | |
| 602 | setsockopt(rv, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); |
| 603 | @@ -1463,10 +1463,10 @@ main(int argc, const char *argv[]) |
| 604 | stdio_console.telnet = 0; |
| 605 | stdio_console.tn_pos = 0; |
| 606 | if (nostdio) { |
| 607 | - stdio_console.out.printf = dummy_printf; |
| 608 | + stdio_console.out.eprintf = dummy_printf; |
| 609 | stdio_console.out.data = &stdio_console; |
| 610 | } else { |
| 611 | - stdio_console.out.printf = emu_printf; |
| 612 | + stdio_console.out.eprintf = emu_printf; |
| 613 | stdio_console.out.data = &stdio_console; |
| 614 | } |
| 615 | stdio_console.next = NULL; |
| 616 | -- |
| 617 | 2.14.1 |
| 618 | |