Homebrew Clarification Thread - What is going on?

Status
Not open for further replies.

msaraiva

Well-Known Member
Newcomer
Joined
Oct 28, 2007
Messages
87
Trophies
0
XP
538
Country
Canada
Steveice10 just added some gotoes into his code. Just saying. (I personally don't like them)

That was exactly my point. Goto is much easier to read and maintain for cleanup then tens of nested ifelses. So calling code in c crap because it uses goto shows low experience in programming. It's not your favorite Java where you can use try finally.

Code:
int initRTC()
{
    char *buf1, *buf2;
    int ret = RTC_OK;
    if ((buf1 = (char *)malloc(20)) == NULL) {
        ret = ERR_RTC_MALLOC1;
    }
    else if ((buf2 = (char *)malloc(40)) == NULL) {
        ret = ERR_RTC_MALLOC2;
    }
    else if (openRTC()) {
        ret = ERR_RTC_OPEN;
    }
    else if (cfgRTC(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_CFG;
    }
    else if (txCmd(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_TX;
    }
    if (ret >= ERR_RTC_CFG) {
        closeRTC();
    }
    if (ret >= ERR_RTC_OPEN) {
        free(buf2);
    }
    if (ret >= ERR_RTC_MALLOC2) {
        free(buf1);
    }
    return ret;
}

Code:
int initRTC()
{
    char *buf1, *buf2;
    int ret = RTC_OK;
    if ((buf1 = (char *)malloc(20)) == NULL) {
        ret = ERR_RTC_MALLOC;
        goto fim0;
    }
    if ((buf2 = (char *)malloc(40)) == NULL) {
        ret = ERR_RTC_MALLOC;
        goto fim1;
    }
    if (openRTC()) {
        ret = ERR_RTC_OPEN;
        goto fim2;
    }
    if (cfgRTC(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_CFG;
        goto fim3;
    }
    if (txCmd(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_TX;
        goto fim3;
    }
fim3:
    closeRTC();
fim2:
    free(buf2);
fim1:
    free(buf1);
fim0:
    return ret;
}

Which one is easier to read/maintain? Now can you all please just shut-up while people that actually know any better do their job?!
 

bbcali89

Well-Known Member
Member
Joined
Sep 16, 2013
Messages
418
Trophies
0
Age
34
Location
Chicago
XP
735
Country
United States
with this new info... it's coming today guaranteed guys. unless they hold back. which they might. who knows.
 

Mrrraou

Well-Known Member
Member
Joined
Oct 17, 2015
Messages
1,873
Trophies
0
XP
2,364
Country
France
I noticed this too. odd.
is it general ? or do they have to make a version for each fw ?
We tried on 10.1, 9.2 and 9.0.

--------------------- MERGED ---------------------------

wait, steveice10 doesn't need basical code execution on 9.3+? why he maked a 9.2- thing?
They didn't do a 9.2 thing, as it crashes on 9.2 and 9.0 too.
 

Filo97

Pink = Best colour
Member
Joined
Oct 8, 2015
Messages
4,098
Trophies
1
Location
Hyrule Castle
XP
2,720
Country
Italy
with this new info... it's coming today guaranteed guys. unless they hold back. which they might. who knows.
not garantueed. but maybe 1 or 2 or 3 days.

--------------------- MERGED ---------------------------

They didn't do a 9.2 thing, as it crashes on 9.2 and 9.0 too.
ahhhhhhhh. can it load code on 9.3+?
 

andriy921

Well-Known Member
Member
Joined
Dec 1, 2015
Messages
268
Trophies
0
Age
32
XP
230
Country
T
Code:
int initRTC()
{
    char *buf1, *buf2;
    int ret = RTC_OK;
    if ((buf1 = (char *)malloc(20)) == NULL) {
        ret = ERR_RTC_MALLOC1;
    }
    else if ((buf2 = (char *)malloc(40)) == NULL) {
        ret = ERR_RTC_MALLOC2;
    }
    else if (openRTC()) {
        ret = ERR_RTC_OPEN;
    }
    else if (cfgRTC(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_CFG;
    }
    else if (txCmd(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_TX;
    }
    if (ret >= ERR_RTC_CFG) {
        closeRTC();
    }
    if (ret >= ERR_RTC_OPEN) {
        free(buf2);
    }
    if (ret >= ERR_RTC_MALLOC2) {
        free(buf1);
    }
    return ret;
}

Code:
int initRTC()
{
    char *buf1, *buf2;
    int ret = RTC_OK;
    if ((buf1 = (char *)malloc(20)) == NULL) {
        ret = ERR_RTC_MALLOC;
        goto fim0;
    }
    if ((buf2 = (char *)malloc(40)) == NULL) {
        ret = ERR_RTC_MALLOC;
        goto fim1;
    }
    if (openRTC()) {
        ret = ERR_RTC_OPEN;
        goto fim2;
    }
    if (cfgRTC(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_CFG;
        goto fim3;
    }
    if (txCmd(buf1, 20, buf2, 40)) {
        ret = ERR_RTC_TX;
        goto fim3;
    }
fim3:
    closeRTC();
fim2:
    free(buf2);
fim1:
    free(buf1);
fim0:
    return ret;
}

Which one is easier to read/maintain? Now can you all please just shut-up while people that actually know any better do their job?!
The code in memchunkhax is very different. Use single cleanup logic and add actions beteen validity checks and ifelse approach looses without options.
 
Status
Not open for further replies.
General chit-chat
Help Users
  • Skelletonike @ Skelletonike:
    Great plot too
  • Vetusomaru @ Vetusomaru:
    psychic academy. lol. it was meh even back then when i bought volume 1. also same author also made one of the manga adaptions of Escaflowne.
  • Skelletonike @ Skelletonike:
    Pfffft!
  • Skelletonike @ Skelletonike:
    I have all the volumes.
  • Vetusomaru @ Vetusomaru:
    btw do u have discord?
  • Vetusomaru @ Vetusomaru:
    last tv anime i remember with nipples i personally watched was Senran Kagura
  • Skelletonike @ Skelletonike:
    yeah I do
  • Skelletonike @ Skelletonike:
    I mostly read, haven't watched much, but I do keep my cunchyroll sub.
  • Skelletonike @ Skelletonike:
    Found out one of my fave animes got an adaptation this season

    the other day lol
  • Skelletonike @ Skelletonike:
    Yuusha ga Shi
    nda
  • Vetusomaru @ Vetusomaru:
    crynchyrolls is cancer, especially with the censorship they do like they did with Oshimai
  • Vetusomaru @ Vetusomaru:
    can u post your discord here or at dm?
  • Skelletonike @ Skelletonike:
    No idea
  • Skelletonike @ Skelletonike:
    it's my username
  • Vetusomaru @ Vetusomaru:
    and number?
  • Skelletonike @ Skelletonike:
    it needs the number?
  • Vetusomaru @ Vetusomaru:
    okey dokey. i ve sent u friend request.
  • Vetusomaru @ Vetusomaru:
    i have same username with here
  • Skelletonike @ Skelletonike:
    alright, accepted
    +1
  • K3N1 @ K3N1:
    You got a friend in you
  • Skelletonike @ Skelletonike:
    that's gay
  • K3N1 @ K3N1:
    Maybe I like being gay
    K3N1 @ K3N1: Maybe I like being gay