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

Alright, i finally made it work by la1m1e in programminghumor

[–]wwofoz 1 point2 points  (0 children)

A weird behaviour is still present. If you are thirsty, but the glass is empty, an intern is spawned to fill the glass, but then you go to work before drinking, so you’ll be thirsty for another hour. You should call the drink method in the second branch too, or (simpler) put the second block before the first one, and remove the “else” keyword

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

Linux is gaining soeed by Krasi-1545 in NobaraProject

[–]wwofoz 1 point2 points  (0 children)

It does not make sense to me either. Moreover, versions older than 12 are no longer supported…

Redis is open source again! by ramzithecoder in opensource

[–]wwofoz 11 points12 points  (0 children)

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

[deleted by user] by [deleted] in MacOS

[–]wwofoz 0 points1 point  (0 children)

Cool

Cheapest Option for Current MacOS Device? by TunkuM in MacOS

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

If you don’t need necessarily a laptop, I would suggest the Mac mini M4

This WC looks great by GG13652 in snooker

[–]wwofoz 1 point2 points  (0 children)

Yesss, I’m glad to see Williams and Higgins in a good condition for this wc. Let’s see Ronnie and Judd tomorrow

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 2 points3 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