OSDN Git Service

tunerec: fix while(), helpmsg
authorLong.inus <longinus@example.com>
Wed, 1 May 2013 20:43:56 +0000 (05:43 +0900)
committerLong.inus <longinus@example.com>
Wed, 1 May 2013 20:43:56 +0000 (05:43 +0900)
tunerec/tunerec.c

index 0a1d1fe..6be978f 100755 (executable)
@@ -113,9 +113,9 @@ void record(int adapter_nr, char* output, int rectime) {
        sprintf(input, "/dev/dvb/adapter%d/dvr0", adapter_nr);
        start_time = time(NULL);
        fin = open(input, (O_RDONLY));
-       while ( rt = read(fin, buf, 1316) > 0 ) {
+       while ( ( rt = read(fin, buf, 1316) ) > 0 ) {
                shift = 0;
-               while ( wt = write(fout, buf + shift, rt) > 0) {
+               while ( ( wt = write(fout, buf + shift, rt) ) > 0) {
                        rt -= wt;
                        if ( rt == 0 ) break;
                        shift += wt;
@@ -147,18 +147,13 @@ int main(int argc, char *argv[]) {
        int rectime;
 
        if (argc <= 2) {
-               fprintf(stderr, "Usage: %s adapter_nr freq [tsid]\n", argv[0]);
+               fprintf(stderr, "Usage: %s adapter_nr freq tsid rectime output\n", argv[0]);
                return 1;
        }
        adapter_nr = strtol(argv[1], NULL, 0);
        channel_freq = strtol(argv[2], NULL, 10);
-       channel_id = rectime = 0;
-       if ( argc >= 4 ){
-               channel_id = strtol(argv[3], NULL, 10);
-       }
-       if ( argc >= 5 ) {
-               rectime = atoi(argv[4]);
-       }
+       channel_id = strtol(argv[3], NULL, 10);
+       rectime = atoi(argv[4]);
        fd = search(adapter_nr, channel_freq, channel_id);
        if (fd < 0)
                return 1;