<commit_before>#include "spdy_setup.h"         /* MUST be the first header to include */
#include "spdy_data_frame.h"
#include "spdy_log.h"
#include "spdy_error.h"
#include "spdy_bytes.h"

#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>

/* Minimum length of a data frame. */
const uint8_t SPDY_DATA_FRAME_MIN_LENGTH = 8;

int spdy_data_frame_init(spdy_data_frame *frame)
{
  frame->stream_id = 0;
}

/**
 * Parse the header of a data frame. This needs 'stream_id' to be cleared to
 * consider this as the first call.
 *
 * @param frame - Target data frame.
 * @param data - Data to parse.
 * @see spdy_data_frame
 * @return Errorcode
 */
int spdy_data_frame_parse_header(spdy_data_frame *frame, spdy_data *data)
{

  /* Check if the frame header has already been parsed. */
  if(!frame->stream_id) {
    size_t length = data->data_end - data->cursor;
    if(length < SPDY_DATA_FRAME_MIN_LENGTH) {
      SPDYDEBUG("Insufficient data for data frame.");
      data->needed = SPDY_DATA_FRAME_MIN_LENGTH - length;
      return SPDY_ERROR_INSUFFICIENT_DATA;<commit_msg>spdy_data_frame_init: add missing return code<commit_after>#include "spdy_setup.h"         /* MUST be the first header to include */
#include "spdy_data_frame.h"
#include "spdy_log.h"
#include "spdy_error.h"
#include "spdy_bytes.h"

#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>

/* Minimum length of a data frame. */
const uint8_t SPDY_DATA_FRAME_MIN_LENGTH = 8;

int spdy_data_frame_init(spdy_data_frame *frame)
{
  frame->stream_id = 0;
  return SPDY_ERROR_NONE;
}

/**
 * Parse the header of a data frame. This needs 'stream_id' to be cleared to
 * consider this as the first call.
 *
 * @param frame - Target data frame.
 * @param data - Data to parse.
 * @see spdy_data_frame
 * @return Errorcode
 */
int spdy_data_frame_parse_header(spdy_data_frame *frame, spdy_data *data)
{

  /* Check if the frame header has already been parsed. */
  if(!frame->stream_id) {
    size_t length = data->data_end - data->cursor;
    if(length < SPDY_DATA_FRAME_MIN_LENGTH) {
      SPDYDEBUG("Insufficient data for data frame.");
      data->needed = SPDY_DATA_FRAME_MIN_LENGTH - length;
      return SPDY_ERROR_INSUFFICIENT_DATA;
{'fraction_non_alphanumeric': 0.109107303877367, 'fraction_numerical': 0.002705139765554554, 'mean_word_length': 4.00902934537246, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5072083', 'n_tokens_mistral': 795, 'n_tokens_neox': 779, 'n_words': 211}