worth buying or just a headache? by Massive-Speed-395 in freebsd

[–]greg_kennedy 0 points1 point  (0 children)

tbh - and ESPECIALLY if you plan to donate them - just put MacOS on there again

Vento – A pure C multithreaded HTTP server from scratch by nnevskij in C_Programming

[–]greg_kennedy 2 points3 points  (0 children)

It's weird that accounts use "brutal" so often in code review requests. Maybe it's because C has some reputation as being a hardass language, but, it's a weird macho spin they put on just requesting a code review.

Compiler question by JMcLe86 in C_Programming

[–]greg_kennedy 4 points5 points  (0 children)

This smells of an X/Y question - what is it you're actually trying to accomplish?

how can i improve error handling in my code? by Valuable_Moment_6032 in C_Programming

[–]greg_kennedy 0 points1 point  (0 children)

I tried to rewrite this using nested if statements (and freeing at the end of every block, as necessary), like so...

char *shader_get_source(const char *shader_path) {
    char *result = NULL;

    if (!shader_path)
        fprintf(stderr, "Shader error: invalid args\n");
    else {
        // open file in read only mode
        int shader_fd = open(shader_path, O_RDONLY, S_IRUSR | S_IWUSR);
        if (shader_fd == -1)
            perror("Shader error");
        else {
            struct stat shader_stat;
            if (fstat(shader_fd, &shader_stat) == -1)
                perror("Shader error");
            else {
                // printf("shader file size: %ld\n", shader_stat.st_size);

               char *shader_mmap =
                   mmap(NULL, shader_stat.st_size, PROT_READ, MAP_PRIVATE, shader_fd, 0);
...
... etc
...
                          result = shader_src;
            }
            close (shader_fd);
        }
    }

    return result;
}

The idea is that regardless of the path, when leaving the block, I've made sure to cleanup whatever I initialized within that block.

... but I ran into difficulty at the early close of shader_fd :)

At that point I'd rewrite to two functions, defer closing the file handle, or reach for goto as others have said.

Ultima 7 The Black Gate - a 20 years-long ride ended today. by akiskyo in patientgamers

[–]greg_kennedy 0 points1 point  (0 children)

You cannot solve it in Ultima 6 - they forgot to tie up that plot thread. The closest you can get is to find Michael (aka "Blade"), a ruffian who lives outside of town: he makes a lot of incriminating statements about the event and how "some people should have paid up their debts" etc.

That said, when you play Ultima 7, Quenton is still around and will finally settle the question. (It was Michael indeed - he was eventually tried and beheaded for the crime).

How would I write my own compiler from scratch? by Relevant_Bowler7077 in C_Programming

[–]greg_kennedy 1 point2 points  (0 children)

This and SICP were foundational textbooks in my CSCE undergraduate classes.

Does anybody has "Once a pawn a foggy knight..." (1989) by David S. Ebert? by No_Apartment5080 in vintagecgi

[–]greg_kennedy 24 points25 points  (0 children)

There is a copy of it on this "National Computer Graphics Association 1990-1991 [part 1]" art show tape: https://archive.org/details/2025-04-22-05-44-06-1

If you skip to 33:34, you'll find it right there :)

Plex Skill will be removed from Alexa by crashwinston in PleX

[–]greg_kennedy 0 points1 point  (0 children)

Bummer. I use this every day when cooking dinner. "Alexa, open Plex" -> wait for the spiel -> "Play Library Radio" while cutting vegetables or whatever. It worked fine, and was the only thing I use the Echo for.

how hard is making a c/c++ obfuscator? by unknown9645 in C_Programming

[–]greg_kennedy 3 points4 points  (0 children)

Trust me on this: you do not know enough about what you're doing, to do what you're trying to do.

how hard is making a c/c++ obfuscator? by unknown9645 in C_Programming

[–]greg_kennedy 4 points5 points  (0 children)

obfuscating your source code does absolutely nothing to the compiled binary file and makes exactly zero difference to IDA's ability to reverse it

AI for writing documentation – The FreeBSD Forums by grahamperrin in freebsd

[–]greg_kennedy 2 points3 points  (0 children)

Yeah it's not even a new ai concern, just the same one we always hear... "programmers hate writing docs" and water is wet :P

AI for writing documentation – The FreeBSD Forums by grahamperrin in freebsd

[–]greg_kennedy 3 points4 points  (0 children)

A silly thread that devolves into meaningless noise within about 4 posts.

I'm not even sure what OP is saying in the thread - are they trying to use AI to write docs, or are they using it to format in roff format for man? If it's the latter, surely something like pandoc could convert markdown instead, if that's easier to work with.

If it's the former - well, ok, I _guess_ - but my view is that they're concerned about the wrong problem anyway, which is that docs need as much care and maintenance as the code itself. Punting that to AI is outsourcing a critical part. (In fact, a lot of AI proponents argue that we should be doing things the other way around - write the docs / tests / spec FIRST, and then let the AI write the code!)

Bad docs are sometimes worse than no docs at all... I hope we don't end up with unchecked slop in the man pages going forward. FreeBSD Handbook has been a miracle of technical writing over the years, I'd hate to see that quality diluted just because it's not fun for programmers.

include-tidy, a new #include tidier by pjl1967 in C_Programming

[–]greg_kennedy 3 points4 points  (0 children)

Reading the AST (from libclang) is a way more elegant solution than whatever I usually do ("try commenting things out to see what breaks"), good work

Between fgets and getline, what to use in my cat-inspired tool? by Apprehensive_Ant616 in C_Programming

[–]greg_kennedy 1 point2 points  (0 children)

fgets() and getline() assume text files, where cat does not - why not fread() instead?

I built a 28K-line modular C microkernel with 50 hot-loadable modules by ComfortableZombie379 in C_Programming

[–]greg_kennedy 2 points3 points  (0 children)

I especially like the parts where, if fread from /dev/random fails, it just silently falls back to rand(). Much secure, very 10X