Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Comment Re:Moving to a future where you pay for freedom (Score 1) 111

you pay - either in money or time or experience - for more freedom. Either freedom of privacy

Or you pay for the illusion of privacy, such as getting AT&T with the death star's ever watchful eye on your traffic plus ads for $70 or for only $30 more you can turn off the ads but not turn off the traffic monitoring.

Comment Re:GOTO is a crutch for bad programmers (Score 1) 677

This compiles in my head (it's been a looooong time since I last touched C) and uses three allocations and several places that can fail.

/* Write no more than 1024 bytes to a new file.txt */
if (-1 != (dest = creat("file.txt", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP))) {
  if (-1 != (src = open("source.txt"))) {
    if (NULL != (buf = calloc(1024, 1))) {
      if (-1 != (rd = read(src, buf, 1024))) { /* should reading zero bytes be an error? */
        total_written = 0;
        buf_p = buf;
        break_loop = 0; /* because break is just another name for goto */
        while (total_written < rd && !break_loop) {
          if (-1 != (wr = write(dest, buf_p, rd-total_written))) {
            total_written += wr;
            buf_p += wr;
          } else {
            break_loop = 1; /* TODO check errno for fixable errors like EAGAIN or EINTR */
            perror("Error writing to file");
          }
        }
      } else {
        perror("Read failed");
      }
      free(buf);
    } else {
      perror("Memory allocation error");
    }
    close(src);
  } else {
    perror("Unable to open source.txt");
  }
  close(dest);
} else {
  perror("Unable to create file.txt");
}

Feel free to bash and/or offer constructive criticism. There's probably some official order to how things should be allocated but I don't know what it is. Maybe memory and sourcefile should have come first to minimize filesystem impact. First thought is that the loop in the middle could be moved to a function to move x bytes from file a to file b using buffer c which relies on x a b c correctness instead of testing it.

Comment Re:Don't forget (Score 1) 330

I house-sat for my sister once years ago, and she had an AV receiver that was hooked up to a DVD player. Once I got bored watching DVDs I tried hooking up my playstation but couldn't get any sound. It took me several hours to accidentally realize that the genius who created it thought it would be a great idea to have completely independent audio and video inputs so even after selecting Video 2, the DVD audio (which was off) was still coming out the speakers.

Comment Re:Fuck beta? (Score 1) 327

I don't know on beta, but on non beta, you go to your preferences (the gear next to the post anonymously checkbox) and choose "Plain Old Text" for your "Comment Post Mode". This gives you the bastard child that is forum style posting, where you can write HTML if you feel like it or you can write whatever and as long as it doesn't look like HTML it will just work but as soon as you want to write < you better break out your html entities guide.

Also remember, two enters is a paragraph.

Comment Re:Don't say I didn't warn you. (Score 1) 79

I don't know about "the" geek, but I'm curious whether, say, Somalia's government is organized enough to set up a PRISM-level metadata collection scheme across its entire communication infrastructure.

Personally, though, I assume that the NSA is double-tapping all of the communications in all of the countries outside of the US since they're already tapping all of the communications inside of it.

Slashdot Top Deals

Business is a good game -- lots of competition and minimum of rules. You keep score with money. -- Nolan Bushnell, founder of Atari

Working...