Page MenuHomeFreeBSD

printf.9: Update the example for %D conversion specifier
ClosedPublic

Authored by zlei on Apr 13 2023, 4:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 12, 11:09 AM
Unknown Object (File)
Tue, May 7, 8:41 AM
Unknown Object (File)
Sun, May 5, 3:16 AM
Unknown Object (File)
Sun, May 5, 1:10 AM
Unknown Object (File)
Sat, May 4, 9:21 PM
Unknown Object (File)
Wed, May 1, 1:49 PM
Unknown Object (File)
Dec 23 2023, 12:55 AM
Unknown Object (File)
Dec 12 2023, 5:30 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

zlei requested review of this revision.Apr 13 2023, 4:03 AM
gbe added a subscriber: gbe.

LGTM from manpages

Markup looks good, but I haven't tested the example itself.

In D39543#900185, @gbe wrote:

LGTM from manpages

Markup looks good, but I haven't tested the example itself.

Tested with a minimal kernel module:
foo.c:

#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>

static void
printf_test(void)
{
        printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE");
        printf("out: %4D\n", "AAZZ", ":");
}

/*
 * The function called at load/unload.
 */
static int
load(module_t mod, int cmd, void *arg)
{
        int error;

        error = 0;
        switch (cmd) {
        case MOD_LOAD:
                printf("Load foo\n");
                printf_test();
                break;
        case MOD_UNLOAD:
                printf("Unload foo\n");
                break;
        default:
                error = EOPNOTSUPP;
                break;
        }
        return (error);
}

static moduledata_t mod_data = {
        "foo",
        load,
        0
};

DECLARE_MODULE(foo, mod_data, SI_SUB_EXEC, SI_ORDER_ANY);

Makefile:

#	$FreeBSD$
PACKAGE=foo
SRCS	= foo.c
KMOD	= foo

.include <bsd.kmod.mk>

Steps to test:

# make
# kldload ./foo.ko
# kldunload foo.ko
# dmesg | tail

Load foo
reg=3<BITTWO,BITONE>
out: 41:41:5a:5a
Unload foo
This revision was not accepted when it landed; it landed in state Needs Review.Apr 14 2023, 10:10 AM
This revision was automatically updated to reflect the committed changes.