Fix: handle packet_seek errors
[babeltrace.git] / converter / babeltrace-log.c
index 210bd09152a11b03907300c4c9b807abbad77983..c478b004d71cf1ecf844c339db46db6fa912c3eb 100644 (file)
@@ -24,8 +24,6 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- * Depends on glibc 2.10 for getline().
  */
 
 #include <sys/types.h>
@@ -45,6 +43,7 @@
 #include <babeltrace/ctf/types.h>
 #include <babeltrace/compat/uuid.h>
 #include <babeltrace/compat/utc.h>
+#include <babeltrace/compat/stdio.h>
 #include <babeltrace/endian.h>
 
 #define NSEC_PER_USEC 1000UL
@@ -283,7 +282,8 @@ void trace_string(char *line, struct ctf_stream_pos *pos, size_t len)
                if (!ctf_move_pos(&dummy, tlen * CHAR_BIT))
                        packet_filled = 1;
                if (packet_filled || ctf_pos_packet(&dummy)) {
-                       ctf_pos_pad_packet(pos);
+                       if (ctf_pos_pad_packet(pos))
+                               goto error;
                        write_packet_header(pos, s_uuid);
                        write_packet_context(pos);
                        if (attempt++ == 1) {
@@ -316,7 +316,7 @@ void trace_text(FILE *input, int output)
        struct ctf_stream_pos pos;
        ssize_t len;
        char *line = NULL, *nl;
-       size_t linesize;
+       size_t linesize = 0;
        int ret;
 
        memset(&pos, 0, sizeof(pos));
@@ -329,7 +329,7 @@ void trace_text(FILE *input, int output)
        write_packet_header(&pos, s_uuid);
        write_packet_context(&pos);
        for (;;) {
-               len = getline(&line, &linesize, input);
+               len = bt_getline(&line, &linesize, input);
                if (len < 0)
                        break;
                nl = strrchr(line, '\n');
This page took 0.023548 seconds and 4 git commands to generate.