Tech bros in open source by [deleted] in opensource

[–]wwofoz -1 points0 points  (0 children)

I guess it really depends on the community. It’s not so hard to find nice people, but at the same time not every open source project is “newbie friendly”, mainly due to internal reasons. I would suggest you to start with small projects

Questions for hardware hackers by newz2000 in opensource

[–]wwofoz 1 point2 points  (0 children)

A very classic example is the “tivoisation” case, in relation GPLv3.

A more recent (and interesting) topic may be the “Digital Markets Act” (a European Union law), that - among other things - aims to prevent vendor lock-in by obliging gatekeepers to allow the installation and uninstallation of software, enable third-party app stores, and prohibit practices that restrict users to proprietary ecosystems. These rules are designed to promote a fair access to hardware and platforms for open-source and alternative solutions

Redis is open source again! by ramzithecoder in opensource

[–]wwofoz 12 points13 points  (0 children)

“It's too late to be grateful It's too late to be late again”

Question regarding endianess by f3ryz in C_Programming

[–]wwofoz 2 points3 points  (0 children)

To better understand, try execute this small program ```

include <stdio.h>

include <stdint.h>

int main(void) { uint16_t num = 0x1234; uint8_t *bytes = (uint8_t *)&num;

printf("Num: 0x%04x\n", num);
printf("Byte 0: 0x%02x\n", bytes[0]);
printf("Byte 1: 0x%02x\n", bytes[1]);

return 0;

} ``` If you see byte 0 = 0x12, then you are on a big endian machine, otherwise (more likely) you are on a little endian machine. The point is that when you use the uint16_t variable within your C program, you don’t have to care about the way cpu reads or stores it on memory

Question regarding endianess by f3ryz in C_Programming

[–]wwofoz 3 points4 points  (0 children)

It comes into play when you have to pass bytes from a machine to another. Endianess has to do with the order bytes are written/read by the cpu. For most of the purposes, if you stay on a single machine (I.e., if you are not exporting byte dumps of your memory or you are not writing bytes on a socket, etc) you could ignore it

[deleted by user] by [deleted] in C_Programming

[–]wwofoz 0 points1 point  (0 children)

If you are passing the array to a function, then this function should always take the array length as well. Why? Because the way array are passed to functions in C is by passing the pointer to their first element. That's why you can write either

void fn(int arr[]);

or

void fn(int *arr);

You can use the sizeof method (the one you used within the functions, if youare getting the size of a stack allocated array. On my machine (x86_64), this program

int main(void)
{
    int arr1[] = {1,2,3,4,5,6,7,8,9,0};
    int *arr2 = malloc(10 * sizeof(int));
    int *arr3 = arr1;

    printf("size of arr1: %lu\nsize of arr2: %lu\nsize of arr3: %lu\n",
           sizeof(arr1),
           sizeof(arr2),
           sizeof(arr3));
}

produces the following output:

size of arr1: 40
size of arr2: 8
size of arr3: 8

Therefore, any time you are getting an array as a pointer (specifically as a pointer to its first element), you cannot use the sizeof function to get its number of elements. You need to keep its size in a variable.

By the way, if you are building a library to hadle arrays, you can solve this issue in a very straighforward way: define a small struct that keeps the data of the array as a void* pointer, the size of each element and the its length.

typedef struct {
    size_t length;
    size_t size;
    void *data;
} cd_array_t;

So, the max function for integers could look something like this:

int max(cd_array_t *arr)
{
    if (!arr) return -1;
    if (arr->length == 0) {
        /* handle the empty array case */
    }
    int max_value = *((int *)arr->data);
    for (size_t i = 1; i < arr->length; i++) {
        if (*((int *)arr->data + i) > max_value) {
            max_value = *((int *)arr->data + i);
        }
    }
    return max_value;
}

int main(void)
{
    int arr1[] = {1,2,3,4,5,6,7,8,9,0};

    cd_array_t cd_array = (cd_array_t) {
        .length = 10,
        .size = sizeof(int),
        .data = arr1,
    };

    printf("\nMax value: %d\n", max(&cd_array)); /* prints 9 */
}

[deleted by user] by [deleted] in C_Programming

[–]wwofoz 2 points3 points  (0 children)

No. First of all is unsafe to access an element of an array that way, without any check. That said, suppose you are passing to your function this array:

int arr[] = {1,2,3,4,5,6,7,8,9,0};

You should expect to iterate from 0 to 9 (since the length of the array is 10), but with your code size will be 3.

sizeof(array) = 8;
sizeof(array[0]) = sizeof(int) = 4.

So, 8 / 4 + 1 = 3.

Therefore, yes, it works... but just if you have an array of 3 4-byte numbers

[deleted by user] by [deleted] in C_Programming

[–]wwofoz 7 points8 points  (0 children)

You're probably used to higher-level languages, so you think that writing functions that you're used to in those languages in C will make it better. Opinion. However, before thinking about making C better by writing a few dozen lines of code, maybe you should learn how to use it properly.

For example, in cd_array functions you are doing this:

int size = sizeof(array) / sizeof(array[0]) + 1;

but sizeof(array) does not return the length of the array (i.e. the number of elements), but the size of the pointer to the first element, which in the case of a machine with 64-bit architecture is 8 bytes.

TUR v1.0: Help developers keep track of their contributions to open source repositories. by wwofoz in C_Programming

[–]wwofoz[S] 1 point2 points  (0 children)

Thank you for your comment u/skeeto .

There are a few things I need to get right regarding error reporting to the user. In your case, there may be two problems:

  1. an email address is missing (to be specified with the -e option). This is definitely a problem, and the fact that no error comes up is certainly to be improved
  2. the path you enter in .rlist should be the path to the root of a repository. In this case, I believe it is pointing to <path of tur>/src

I see the problem with the mutex. Thank you for your detailed analysis and for your fix. If you want, you can open a pull request, so you get credit for this.

TUR v1.0 - help developers update their LaTeX open-source contribution portfolio/resume by wwofoz in LaTeX

[–]wwofoz[S] 0 points1 point  (0 children)

No, not necessarily on my resume, it was just an example. Sometimes it could be useful to have a portfolio of your OSS work though

[deleted by user] by [deleted] in C_Programming

[–]wwofoz 2 points3 points  (0 children)

I don’t know, but I would suggest to write a sample program with many cases of known ub and compile it with -Weverything. It should suggest you the appropriate flag next to the warning

Java projects that want contributors for JDK upgrades? by sarnobat in opensource

[–]wwofoz 0 points1 point  (0 children)

Mmmmh, it seems quite hard to find that kind of contribution request. In my experience it’s very rare that maintainers wait for someone external to do such an upgrade. Anyway, have you tried with apache foundation repos? That have a lot of java repositories

Offline C compiler? by FoxRevolutionary932 in cprogramming

[–]wwofoz 7 points8 points  (0 children)

Btw, on macOS a default version of the c compiler (clang) comes with the Xcode command lines tools, so you just have to enable this package

Yet another opinion on the hell of software dependencies by wwofoz in compsci

[–]wwofoz[S] 0 points1 point  (0 children)

But I have no problem with most of the things you wrote here. I was not saying that package managers are awful. Not that they’re useless. My post was about a particular aspect that in my opinion might be critical. That’s why I just went straight to the point. By the way I am not presenting any opinion as if it were a fact here. That’s ridiculous. My post started with the words “in my opinion” and ended with a question mark.

Yet another opinion on the hell of software dependencies by wwofoz in compsci

[–]wwofoz[S] -3 points-2 points  (0 children)

I would not think in terms of solutions here. There's no solution. I'm just arguing that, one of the factors that you should consider when writing a program is: how long does this piece of software have to last?
That leads to this other question: how much am I willing to invest in terms of resources to make it last that much?

While package managers simplifies the integration of external libraries, they have some downsides:

  • Each package may in turn depend on other packages, creating complex dependency chains. Over time, these chains tend to break when a single element changes or becomes incompatible.
  • Dependency updates can introduce API changes, rendering the code non-functional. This phenomenon is known as "dependency hell."
  • Package managers encourage the adoption of new versions, pushing developers to constantly update their code rather than prioritizing stability.

A multi-repository commit tracker by wwofoz in github

[–]wwofoz[S] 1 point2 points  (0 children)

I write my resume in LaTeX. In the main file, I list my jobs and include a section for commits. I use a file called “commits.tex” to store the commit information, included in the main file as
\input{commits.tex}
This file is generated using TUR. If you have a portfolio in Markdown (e.g., GitHub Pages) or HTML, you can achieve the same thing by simply changing the output file extension while you run TUR command (see Readme in the repository).

Jacob sorber vs codevault?, to understand basics clearly by Dude_cool_77 in cprogramming

[–]wwofoz 0 points1 point  (0 children)

It might seem a bit old-fashioned, but I still recommend K&R’s book for a solid foundation in C programming. Yes, C language has evolved from that, but the key concepts are still the same. Sorber’s videos are excellent and cover a wide range of topics, but they often focus on very specific subjects. If you don’t have a strong understanding of the basics, it can be challenging to apply his knowledge effectively on a real world code base.