<commit_before>package org.westmalle.launch.direct;

import com.google.auto.factory.AutoFactory;
import com.google.auto.factory.Provided;
import org.freedesktop.jaccall.Pointer;
import org.freedesktop.jaccall.Ptr;
import org.westmalle.Signal;
import org.westmalle.Slot;
import org.westmalle.launch.Privileges;
import org.westmalle.nativ.glibc.Libc;
import org.westmalle.nativ.libdrm.Libdrm;
import org.westmalle.tty.Tty;

import javax.annotation.Nonnull;

@AutoFactory(allowSubclasses = true,
             className = "PrivateDirectPrivilegesFactory")
public class DirectPrivileges implements Privileges {

    private final Signal<Object, Slot<Object>> activateSignal   = new Signal<>();
    private final Signal<Object, Slot<Object>> deactivateSignal = new Signal<>();

    @Nonnull
    private final Libc   libc;
    @Nonnull
    private final Libdrm libdrm;
    @Nonnull
    private final Tty    tty;

    DirectPrivileges(@Provided @Nonnull final Libc libc,
                     @Provided @Nonnull final Libdrm libdrm,
                     @Provided @Nonnull final Tty tty) {
        this.libc = libc;
        this.libdrm = libdrm;
        this.tty = tty;
    }

    @Override
    public void switchTty(final int vt) {
        this.tty.activate(vt);
    }

    @Override
    public int open(@Ptr(String.class) final long path,
                    final int flags) {
        return this.libc.open(Pointer.nref(path).address,
                              flags);
    }

    @Override
    public void setDrmMaster(final int fd) {
        this.libc.setErrno(0);
        if (this.libdrm.drmSetMaster(fd) != 0) {
            throw new RuntimeException("failed to set drm master: " + this.libc.getStrError());
        }
    }

    @Override
    public void dropDrmMaster(final int fd) {
        this.libc.setErrno(0);
        if (this.libdrm.drmDropMaster(fd) != 0) {
            throw new RuntimeException("failed to drop drm master: " + this.libc.getStrError());
        }
    }

    @Override
    public Signal<Object, Slot<Object>> getActivateSignal() {
        return this.activateSignal;
    }

    @Override
    public Signal<Object, Slot<Object>> getDeactivateSignal() {
        return this.deactivateSignal;
    }
}<commit_msg>dont reset error code<commit_after>package org.westmalle.launch.direct;

import com.google.auto.factory.AutoFactory;
import com.google.auto.factory.Provided;
import org.freedesktop.jaccall.Pointer;
import org.freedesktop.jaccall.Ptr;
import org.westmalle.Signal;
import org.westmalle.Slot;
import org.westmalle.launch.Privileges;
import org.westmalle.nativ.glibc.Libc;
import org.westmalle.nativ.libdrm.Libdrm;
import org.westmalle.tty.Tty;

import javax.annotation.Nonnull;

@AutoFactory(allowSubclasses = true,
             className = "PrivateDirectPrivilegesFactory")
public class DirectPrivileges implements Privileges {

    private final Signal<Object, Slot<Object>> activateSignal   = new Signal<>();
    private final Signal<Object, Slot<Object>> deactivateSignal = new Signal<>();

    @Nonnull
    private final Libc   libc;
    @Nonnull
    private final Libdrm libdrm;
    @Nonnull
    private final Tty    tty;

    DirectPrivileges(@Provided @Nonnull final Libc libc,
                     @Provided @Nonnull final Libdrm libdrm,
                     @Provided @Nonnull final Tty tty) {
        this.libc = libc;
        this.libdrm = libdrm;
        this.tty = tty;
    }

    @Override
    public void switchTty(final int vt) {
        this.tty.activate(vt);
    }

    @Override
    public int open(@Ptr(String.class) final long path,
                    final int flags) {
        return this.libc.open(Pointer.nref(path).address,
                              flags);
    }

    @Override
    public void setDrmMaster(final int fd) {
        if (this.libdrm.drmSetMaster(fd) != 0) {
            throw new RuntimeException("failed to set drm master: " + this.libc.getStrError());
        }
    }

    @Override
    public void dropDrmMaster(final int fd) {
        if (this.libdrm.drmDropMaster(fd) != 0) {
            throw new RuntimeException("failed to drop drm master: " + this.libc.getStrError());
        }
    }

    @Override
    public Signal<Object, Slot<Object>> getActivateSignal() {
        return this.activateSignal;
    }

    @Override
    public Signal<Object, Slot<Object>> getDeactivateSignal() {
        return this.deactivateSignal;
    }
}
{'fraction_non_alphanumeric': 0.10054347826086957, 'fraction_numerical': 0.001358695652173913, 'mean_word_length': 2.674708818635607, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '2278265', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1315, 'n_words': 307}