<commit_before>#include <stdio.h>
#include <endian.h>

#include <sys/ioctl.h>
#include <sys/epoll.h>

#include <linux/types.h>
#include <linux/limits.h>

#include "internal.h"

HinawaSndUnit *hinawa_snd_unit_create(char *hw_path, int *err)
{
	HinawaSndUnit *unit;
	snd_hwdep_t *hwdep;
	struct snd_firewire_get_info info;
	char *name;

	*err = -snd_hwdep_open(&hwdep, hw_path, SND_HWDEP_OPEN_DUPLEX);
	if (*err)
		return NULL;

	*err = -snd_hwdep_ioctl(hwdep, SNDRV_FIREWIRE_IOCTL_GET_INFO, &info);
	if (*err) {
		snd_hwdep_close(hwdep);
		return NULL;
	}

	hinawa_malloc(unit, sizeof(HinawaSndUnit), err);
	if (*err) {
		snd_hwdep_close(hwdep);
		return NULL;
	}

	*err = snd_card_get_name(info.card, &name);
	if (*err > 0) {
		snd_hwdep_close(hwdep);
		return NULL;
	}
	strncpy(unit->name, name, sizeof(unit->name));
	free(name);
	*err = 0;

	unit->hwdep = hwdep;
	unit->type = info.type;
	unit->card = info.card;
	memcpy(unit->guid, info.guid, sizeof(info.guid));
	memcpy(unit->device, info.device_name, strlen(info.device_name));

	return unit;
}
<commit_msg>Fix returning wrong name for sound card<commit_after>#include <stdio.h>
#include <endian.h>

#include <sys/ioctl.h>
#include <sys/epoll.h>

#include <linux/types.h>
#include <linux/limits.h>

#include "internal.h"

HinawaSndUnit *hinawa_snd_unit_create(char *hw_path, int *err)
{
	HinawaSndUnit *unit;
	snd_hwdep_t *hwdep;
	snd_hwdep_info_t *hwdep_info;
	struct snd_firewire_get_info info;
	char *name;

	*err = -snd_hwdep_open(&hwdep, hw_path, SND_HWDEP_OPEN_DUPLEX);
	if (*err)
		return NULL;

	*err = -snd_hwdep_ioctl(hwdep, SNDRV_FIREWIRE_IOCTL_GET_INFO, &info);
	if (*err) {
		snd_hwdep_close(hwdep);
		return NULL;
	}

	hinawa_malloc(unit, sizeof(HinawaSndUnit), err);
	if (*err) {
		snd_hwdep_close(hwdep);
		return NULL;
	}

	*err = -snd_hwdep_info_malloc(&hwdep_info);
	if (*err) {
		hinawa_free(unit);
		snd_hwdep_close(hwdep);
		return NULL;
	}

	*err = -snd_hwdep_info(hwdep, hwdep_info);
	if (*err == 0)
		*err = snd_card_get_name(snd_hwdep_info_get_card(hwdep_info),
					 &name);
	snd_hwdep_info_free(hwdep_info);
	if (*err) {
		hinawa_free(unit);
		snd_hwdep_close(hwdep);
		return NULL;
	}

	strncpy(unit->name, name, sizeof(unit->name));
	free(name);
	*err = 0;

	unit->hwdep = hwdep;
	unit->type = info.type;
	unit->card = info.card;
	memcpy(unit->guid, info.guid, sizeof(info.guid));
	memcpy(unit->device, info.device_name, strlen(info.device_name));

	return unit;
}

{'fraction_non_alphanumeric': 0.15387755102040818, 'fraction_numerical': 0.0016326530612244899, 'mean_word_length': 5.142857142857143, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 30, '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': '2031985', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1061, 'n_words': 187}