* If filename is NULL, it saves the buffer using flashrom. * Otherwise, it saves the buffer in the given filename. */
| 108 | * Otherwise, it saves the buffer in the given filename. |
| 109 | */ |
| 110 | static int elog_write(struct buffer *buffer, const char *filename) |
| 111 | { |
| 112 | if (filename == NULL) { |
| 113 | if (flashrom_host_write(buffer, ELOG_RW_REGION_NAME) != 0) { |
| 114 | fprintf(stderr, |
| 115 | "Failed to write to RW_ELOG region using flashrom\n"); |
| 116 | return ELOGTOOL_EXIT_WRITE_ERROR; |
| 117 | } |
| 118 | return ELOGTOOL_EXIT_SUCCESS; |
| 119 | } |
| 120 | |
| 121 | if (buffer_write_file(buffer, filename) != 0) { |
| 122 | fprintf(stderr, "Failed to write to file %s\n", filename); |
| 123 | return ELOGTOOL_EXIT_WRITE_ERROR; |
| 124 | } |
| 125 | return ELOGTOOL_EXIT_SUCCESS; |
| 126 | } |
| 127 | |
| 128 | /* Buffer offset must point to a valid event_header struct */ |
| 129 | static size_t next_available_event_offset(const struct buffer *buf) |
no test coverage detected