Add z80 reset, split out monitor key queue

"reset" now enables B3 low for a short time (then disables)
    assumption is that B3 is connected to Z80 /RESET with a pullup
combined "resp" and "cmd" into "buffers"
Make separate serial monitor key queue
    "pass" command sends subsequent serial input to CONIN buffer
    until CTRL-A, CTRL-B as before
AT keyboard keys always go to CONIN buffer
Fix comment about SD card speed, using 40MHz and current multipliers
Make "block_size" a "#define BLOCKSIZE"
Separate SD tests out of main()
Put "clear" and other new commands in usage message
Handle backspace better, beep if over- or underrunning monitor kbd buffer

--- alice2/io_pic_v2/io_pic.c
+++ alice2/io_pic_v2/io_pic.c
@@ -65,7 +65,8 @@
 // Use project enums instead of #define for ON and OFF.

 // CONFIG1H
-#pragma config OSC = RCIO6      // Oscillator Selection bits (External RC oscillator, port function on RA6)
+#pragma config OSC = ECIO6      // Oscillator Selection bits (External RC oscillator, port function on RA6)
+
 #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
 #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

@@ -148,6 +149,11 @@
         pause();
         pause();
     }
+}
+
+void bell()
+{
+    putch('\a');
 }

 void setup()
@@ -160,6 +166,22 @@
     TRISCbits.TRISC1 = 0;
     TRISCbits.TRISC0 = 0;
     LATCbits.LC0 = 0;
+
+    // /RESET control
+    TRISBbits.TRISB3 = 1;       // B3 is /RESET to Z-80 - set to input (disabled)
+    LATBbits.LB3 = 0;           // When B3 is enabled, it will be 0
+}
+
+void master_reset_start()
+{
+    LATBbits.LB3 = 0;           // When B3 is enabled, it will be 0
+    TRISBbits.TRISB3 = 0;       // B3 is /RESET to Z-80 - set to output
+    pause();
+}
+
+void master_reset_finish()
+{
+    TRISBbits.TRISB3 = 1;       // B3 is /RESET to Z-80 - set to output
 }

 int isprint(unsigned char a)
@@ -182,9 +204,65 @@
 int debug = DEBUG_WARNINGS;

 //----------------------------------------------------------------------------
-// Console input queue (could be from serial or from PS/2 keyboard)
-
-#define CON_QUEUE_LENGTH 32
+// Monitor input queue
+
+#define MON_QUEUE_LENGTH 32
+volatile unsigned char mon_queue[MON_QUEUE_LENGTH];
+volatile short mon_queue_next_head = 0;
+volatile short mon_queue_tail = 0;
+
+// Caller must ensure only one call can proceed at a time; currently
+// called through isfull() and isempty(), so must protect those
+unsigned short mon_queue_length()
+{
+    return (mon_queue_next_head + MON_QUEUE_LENGTH - mon_queue_tail) % MON_QUEUE_LENGTH;
+}
+
+// Caller must ensure only one call to isfull() or isempty() can
+// proceed at a time.
+
+// Currently called from main() or intr(), so must wrap with di(), ei()
+unsigned char mon_queue_isfull()
+{
+    return mon_queue_length() == MON_QUEUE_LENGTH - 1;
+}
+
+// Currently called from main(), so, wrap with di(), ei()
+unsigned char mon_queue_isempty()
+{
+    return mon_queue_length() == 0;
+}
+
+// Caller must ensure only one call can proceed at a time ; currently
+// called from main() and intr(), so wrap with di(), ei()
+void mon_enqueue(unsigned char d)
+{
+    mon_queue[mon_queue_next_head] = d;
+    mon_queue_next_head = (mon_queue_next_head + 1) % MON_QUEUE_LENGTH;
+}
+
+// Caller must ensure only one call can proceed at a time; currently
+// called only from main() so already protected
+unsigned char mon_dequeue()
+{
+    unsigned char d = mon_queue[mon_queue_tail];
+    mon_queue_tail = (mon_queue_tail + 1) % MON_QUEUE_LENGTH;
+    return d;
+}
+
+// Call this from ISR, so skip di/ei
+void monitor_enqueue_key_unsafe(unsigned char d)
+{
+    if(!mon_queue_isfull()) {
+        mon_enqueue(d);
+    }
+}
+
+
+//----------------------------------------------------------------------------
+// Console input queue
+
+#define CON_QUEUE_LENGTH 64
 volatile unsigned char con_queue[CON_QUEUE_LENGTH];
 volatile short con_queue_next_head = 0;
 volatile short con_queue_tail = 0;
@@ -226,11 +304,6 @@
     unsigned char d = con_queue[con_queue_tail];
     con_queue_tail = (con_queue_tail + 1) % CON_QUEUE_LENGTH;
     return d;
-}
-
-void console_queue_clear()
-{
-    con_queue_tail = con_queue_next_head;
 }

 void console_enqueue_key(unsigned char d)
@@ -549,8 +622,7 @@
 //----------------------------------------------------------------------------
 // Alice 3 Bus

-volatile unsigned char host_has_contacted;
-volatile unsigned char in_pic_monitor;
+volatile unsigned char serial_is_monitor;
 volatile unsigned char pic_monitor_latch;

 #define PIC_POLL_AGAIN 0x00
@@ -667,7 +739,7 @@
 {
     // Set up SPI for SD card
     // Set TMR2 to /16 pre, /1 comparator, source is Fosc/4,
-    // 20Mhz / 4 / 16 / 5 / 2 = 31.25KHz,  Max out later
+    // 40Mhz / 4 / 16 / 1 / 2 = 312.5KHz

     T2CONbits.T2CKPS = 0b11;    // 1:16 prescale
     PR2 = 1;                    // TMR2 PR2 trigger on 8
@@ -808,6 +880,10 @@

 int timeout_count = 32000;

+#define BLOCK_SIZE 512
+
+unsigned char block_buffer[BLOCK_SIZE];
+
 // cribbed somewhat from http://elm-chan.org/docs/mmc/mmc_e.html
 enum sdcard_command {
     CMD0 = 0,    // init; go to idle state
@@ -951,8 +1027,6 @@
     return 1;
 }

-const unsigned int block_size = 512;
-
 void dump_more_spi_bytes(const char *why)
 {
     unsigned char response[8];
@@ -990,7 +1064,7 @@
     } while(response[0] != sdcard_token_17_18_24);

     // Read data.
-    spi_readn(block, block_size);
+    spi_readn(block, BLOCK_SIZE);

     // Read CRC
     spi_readn(response, 2);
@@ -999,7 +1073,7 @@
     unsigned short crc_theirs = response[0] * 256 + response[1];

     // calculate our version of CRC and compare
-    unsigned short crc_ours = crc_itu_t(0, block, block_size);
+    unsigned short crc_ours = crc_itu_t(0, block, BLOCK_SIZE);

     if(crc_theirs != crc_ours) {
         printf("CRC mismatch (theirs %04X versus ours %04X, reporting failure)\n", crc_theirs, crc_ours);
@@ -1047,7 +1121,7 @@
     spi_writen(response, 1);

     // Send data.
-    spi_writen(block, block_size);
+    spi_writen(block, BLOCK_SIZE);

     // junk CRC
     response[0] = 0xff;
@@ -1104,8 +1178,89 @@
     }
 }

+void test_sd_card()
+{
+#if 0 // XXX original_block cannot be allocated on 18F452 with all other stuff
+    unsigned int u;
+    int i;
+    int success;
+    int block_number;
+    static unsigned char original_block[BLOCK_SIZE];
+
+    // test SD card
+    block_number = 0;
+
+    for(;;) {
+        printf("block %d\n", block_number);
+        // printf("Reading a block\n");
+        if(!sdcard_readblock(block_number, original_block)) {
+            panic();
+        }
+        // printf("Original block:\n");
+        // dump_buffer_hex(4, original_block, BLOCK_SIZE);
+
+        for(i = 0; i < BLOCK_SIZE; i++)
+            block_buffer[i] = (original_block[i] + 0x55) % 256;
+
+        if(!sdcard_writeblock(block_number, block_buffer)) {
+            printf("PANIC: Failed writeblock\n");
+            panic();
+        }
+        // printf("Wrote junk block\n");
+
+        for(i = 0; i < BLOCK_SIZE; i++)
+            block_buffer[i] = 0;
+        if(!sdcard_readblock(block_number, block_buffer)) {
+            printf("PANIC: Failed readblock\n");
+            panic();
+        }
+
+        success = 1;
+        for(i = 0; i < BLOCK_SIZE; i++)
+            if(block_buffer[i] != (original_block[i] + 0x55) % 256)
+                success = 0;
+
+        if(!success) {
+            printf("whoops, error verifying write of junk to block 0\n");
+            printf("block read: %02X %02X %02X %02X\n",
+                block_buffer[0], block_buffer[1], block_buffer[2], block_buffer[3]);
+        } else {
+            printf("Verified junk block was written\n");
+        }
+
+        if(!sdcard_writeblock(block_number, original_block)) {
+            printf("PANIC: Failed writeblock\n");
+            panic();
+        }
+        // printf("Wrote original block\n");
+
+        if(!sdcard_readblock(block_number, block_buffer)) {
+            printf("PANIC: Failed readblock\n");
+            panic();
+        }
+
+        success = 1;
+        for(i = 0; i < BLOCK_SIZE; i++)
+            if(original_block[i] != block_buffer[i])
+                success = 0;
+
+        if(!success) {
+            printf("whoops, error verifying write of original to block 0\n");
+            printf("block read: %02X %02X %02X %02X\n",
+                block_buffer[0], block_buffer[1], block_buffer[2], block_buffer[3]);
+        } else {
+            printf("Verified original block was written\n");
+        }
+        block_number ++;
+        if(block_number % 2 == 0)
+            PORTA = 0x0f;
+        else
+            PORTA = 0x00;
+    }
+#endif
+}
+
 int previous_block = 0xffff;
-unsigned char block_buffer[512];

 #define sectors_per_block 4
 #define sectors_per_track 64
@@ -1158,18 +1313,7 @@
     }

     if(RCIF) {
-        static unsigned char c;
-        c = RCREG; // clears RCIF
-        if(pic_monitor_latch == 0 && c == 1)
-            pic_monitor_latch = 1;
-        else if(pic_monitor_latch != 0 && c == 2) {
-            pic_monitor_latch = 0;
-            in_pic_monitor = 1;
-            console_queue_clear();
-        } else {
-            pic_monitor_latch = 0;
-            console_enqueue_key_unsafe(c);
-        }
+        monitor_enqueue_key_unsafe(RCREG); // reading RCREG clears RCIF
     }

     if(INT0IF) {
@@ -1194,12 +1338,13 @@
 void usage()
 {
     printf("help - this help message\n");
+    printf("debug N - set debug level\n");
+    printf("buffers - print summary of command and response buffers\n");
+    printf("reset - reset Z80 and clear communication buffers\n");
+    printf("clear - clear command and response buffer\n");
+    printf("pass - pass monitor keys to Z80\n");
+    printf("version - print firmware build version\n");
     printf("read N - read and dump block\n");
-    printf("exit - exit monitor (keys go to Z80)\n");
-    printf("version - print date of firmware build\n");
-    printf("cmd - print summary of command queue\n");
-    printf("resp - print summary of response queue\n");
-    printf("debug N - set debug level [default 0]\n");
 }

 #define PIC_FIRMWARE_VERSION_STRING XSTR(PIC_FIRMWARE_VERSION)
@@ -1216,29 +1361,41 @@

             usage();

+        } else if(strcmp(local_command, "reset") == 0) {
+
+            master_reset_start();
+            printf("Resetting Z-80 and communication buffers...\n");
+            response_clear();
+            command_clear();
+            master_reset_finish();
+            printf("Reset.\n");
+
         } else if(strcmp(local_command, "clear") == 0) {

             response_clear();
             command_clear();
             printf("command and response data cleared\n");

-        } else if(strcmp(local_command, "exit") == 0) {
-
-            in_pic_monitor = 0;
-
-        } else if(strcmp(local_command, "resp") == 0) {
+        } else if(strcmp(local_command, "pass") == 0) {
+
+            serial_is_monitor = 0;
+            printf("Press CTRL-A then CTRL-B to return to monitor.\n");
+
+        } else if(strcmp(local_command, "buffers") == 0) {
+
+            printf("command request: 0x%02X\n", command_request);
+            printf("command length: %d bytes\n", command_length);
+            if(command_length > 0) {
+                printf("command buffer:\n");
+                dump_buffer_hex(4, command_bytes, command_length);
+            }

             printf("response length: %d bytes\n", response_length);
             printf("response next byte to put on bus: %d\n", response_index);
-            printf("response buffer:\n");
-            dump_buffer_hex(4, response_bytes, response_length);
-
-        } else if(strcmp(local_command, "cmd") == 0) {
-
-            printf("command length: %d bytes\n", command_length);
-            printf("command buffer:\n");
-            dump_buffer_hex(4, command_bytes, command_length);
-            printf("command request: 0x%02X\n", command_request);
+            if(response_length > 0) {
+                printf("response buffer:\n");
+                dump_buffer_hex(4, response_bytes, response_length);
+            }

         } else if(strcmp(local_command, "version") == 0) {

@@ -1260,7 +1417,7 @@
                 p++;
             block_number = strtol(p, NULL, 0);
             if(sdcard_readblock(block_number, block_buffer)) {
-                dump_buffer_hex(4, block_buffer, 512);
+                dump_buffer_hex(4, block_buffer, BLOCK_SIZE);
             }

         } else {
@@ -1271,23 +1428,31 @@

         printf("* ");
         local_command_length = 0;
+
     } else {
+
         if(c == 127 || c == '\b') {
-            putch('\b');
-            if(local_command_length > 0)
+            if(local_command_length > 0) {
+                putch('\b');
+                putch(' ');
+                putch('\b');
                 local_command_length--;
+            } else {
+                bell();
+            }
         } else {
-            putch(c);
-            if(local_command_length < sizeof(local_command) - 1)
+            if(local_command_length < sizeof(local_command) - 1) {
+                putch(c);
                 local_command[local_command_length++] = c;
+            } else {
+                bell();
+            }
         }
     }
 }

 void main()
 {
-    unsigned char was_in_monitor = 0;
-    unsigned char host_had_contacted = 0;
     unsigned char was_response_waiting = 0;
     unsigned char isempty;
     unsigned int u;
@@ -1297,22 +1462,19 @@

     PORTAbits.RA0 = 1; // LEDs *... means we got here

-    host_has_contacted = 0;
-    in_pic_monitor = 1;
+    serial_is_monitor = 1;
     pic_monitor_latch = 0;

     setup();
+
+    setup_serial(); // transmit and receive but global interrupts disabled
+
+    printf("Alice 3 I/O PIC firmware, %s\n", PIC_FIRMWARE_VERSION_STRING);
+
     pause();
     pause();
     pause();
     pause();
-
-    setup_serial(); // transmit and receive but global interrupts disabled
-
-    printf("Alice 3 I/O PIC firmware, %s\n", PIC_FIRMWARE_VERSION_STRING);
-
-    pause();
-    pause();
     pause();
     pause();

@@ -1323,120 +1485,43 @@
     }
     printf("SD Card interface is initialized for SPI\n");

-#if 0
-    // test SD card
-    block_number = 0;
+    if(0) test_sd_card();
+
+    setup_slave_port();
+
+    setup_keyboard();
+
+    enable_interrupts();
+
+    printf("* ");

     for(;;) {
-        unsigned char originalblock[512];
-        printf("block %d\n", block_number);
-        // printf("Reading a block\n");
-        if(!sdcard_readblock(block_number, originalblock)) {
-            panic();
-        }
-        // printf("Original block:\n");
-        // dump_buffer_hex(4, originalblock, 512);
-
-        for(i = 0; i < 512; i++)
-            block_buffer[i] = (originalblock[i] + 0x55) % 256;
-
-        if(!sdcard_writeblock(block_number, block_buffer)) {
-            printf("PANIC: Failed writeblock\n");
-            panic();
-        }
-        // printf("Wrote junk block\n");
-
-        for(i = 0; i < 512; i++)
-            block_buffer[i] = 0;
-        if(!sdcard_readblock(block_number, block_buffer)) {
-            printf("PANIC: Failed readblock\n");
-            panic();
-        }
-
-        success = 1;
-        for(i = 0; i < 512; i++)
-            if(block_buffer[i] != (originalblock[i] + 0x55) % 256)
-                success = 0;
-
-        if(!success) {
-            printf("whoops, error verifying write of junk to block 0\n");
-            printf("block read: %02X %02X %02X %02X\n",
-                block_buffer[0], block_buffer[1], block_buffer[2], block_buffer[3]);
-        } else {
-            printf("Verified junk block was written\n");
-        }
-
-        if(!sdcard_writeblock(block_number, originalblock)) {
-            printf("PANIC: Failed writeblock\n");
-            panic();
-        }
-        // printf("Wrote original block\n");
-
-        if(!sdcard_readblock(block_number, block_buffer)) {
-            printf("PANIC: Failed readblock\n");
-            panic();
-        }
-
-        success = 1;
-        for(i = 0; i < 512; i++)
-            if(originalblock[i] != block_buffer[i])
-                success = 0;
-
-        if(!success) {
-            printf("whoops, error verifying write of original to block 0\n");
-            printf("block read: %02X %02X %02X %02X\n",
-                block_buffer[0], block_buffer[1], block_buffer[2], block_buffer[3]);
-        } else {
-            printf("Verified original block was written\n");
-        }
-        block_number ++;
-        if(block_number % 2 == 0)
-            PORTA = 0x0f;
-        else
-            PORTA = 0x00;
-    }
-    spi_disable_sd();
-#endif
-
-    PORTA = 0x0;
-
-    setup_slave_port();
-
-    setup_keyboard();
-
-    enable_interrupts();
-
-    for(;;) {
-
-        if(!host_had_contacted && host_has_contacted) {
-            in_pic_monitor = 0;
-        }
-
-        if(in_pic_monitor) {
-            unsigned char c;
-
-            if(!was_in_monitor)
-                printf("\n* ");
-
+
+        unsigned char c;
+
+        di();
+        isempty = mon_queue_isempty();
+        ei();
+
+        if(!isempty) {
             di();
-            isempty = con_queue_isempty();
+            c = mon_dequeue();
             ei();
-
-            if(!isempty) {
-                di();
-                c = con_dequeue();
-                ei();
+            if(serial_is_monitor)
                 process_local_key(c);
+            else {
+                if(pic_monitor_latch == 0 && c == 1)
+                    pic_monitor_latch = 1;
+                else if(pic_monitor_latch != 0 && c == 2) {
+                    pic_monitor_latch = 0;
+                    serial_is_monitor = 1;
+                    printf("Serial input returned to monitor\n");
+                } else {
+                    pic_monitor_latch = 0;
+                    console_enqueue_key(c);
+                }
             }
-
-        } else {
-
-            if(was_in_monitor)
-                printf("Press CTRL-A then CTRL-B to return to monitor.\n");
-        }
-
-        was_in_monitor = in_pic_monitor;
-        host_had_contacted = host_has_contacted;
+        }

         if(command_length > 0) {
             unsigned char command_byte = command_bytes[0];
@@ -1455,7 +1540,6 @@
                     PORTCbits.RC2 = 0; // debug LED: RC2 off means receipt completed
                 }
             }
-            host_has_contacted = 1;
         }

         CLRWDT(); // XXX Why?  SWDTEN and WDTEN are 0!
@@ -1491,7 +1575,7 @@
                             break;
                         }
                         if(debug >= DEBUG_DATA) printf("New cached block\n");
-                        if(debug >= DEBUG_ALL) dump_buffer_hex(4, block_buffer, 512);
+                        if(debug >= DEBUG_ALL) dump_buffer_hex(4, block_buffer, BLOCK_SIZE);
                         previous_block = block_number;
                     }


tests: Add the ability to run test-send-receive on the network

Allows us to easily test whether things work without signalling and much
in the way of candidate gathering.

--- tests/test_send_receive.c
+++ tests/test_send_receive.c
@@ -64,12 +64,16 @@

 static gchar *uri = NULL;
 static gboolean disable_video = FALSE, disable_audio = FALSE, print_messages = FALSE;
+static gchar *local_addr = NULL, *remote_addr = NULL;
+static const char *stun_pass = "5f1f2614f722cd60fbae275193608d4e";

 static GOptionEntry entries[] = {
     { "disable-video", 0, 0, G_OPTION_ARG_NONE, &disable_video, "Disable video", NULL },
     { "disable-audio", 0, 0, G_OPTION_ARG_NONE, &disable_audio, "Disable audio", NULL },
     { "uri", 'u', 0, G_OPTION_ARG_NONE, &uri, "URI to use as source", NULL },
     { "print-messages", 'p', 0, G_OPTION_ARG_NONE, &print_messages, "Prints all messages, instead of just errors", NULL },
+    { "local-address", 'l', 0, G_OPTION_ARG_STRING, &local_addr, "Local candidate address", NULL },
+    { "remote-address", 'r', 0, G_OPTION_ARG_STRING, &remote_addr, "Remote candidate address", NULL },
     { NULL, }
 };

@@ -118,7 +122,87 @@

 static void got_candidate(OwrMediaSession *session_a, OwrCandidate *candidate, OwrMediaSession *session_b)
 {
-    owr_session_add_remote_candidate(OWR_SESSION(session_b), candidate);
+    GList *local_candidates;
+    gchar *addr;
+    guint port, component;
+    guint rtp_port, rtcp_port;
+
+    if (!local_addr || !remote_addr)
+        owr_session_add_remote_candidate(OWR_SESSION(session_b), candidate);
+    else {
+        local_candidates = g_object_get_data(G_OBJECT(session_a), "local-candidates");
+        local_candidates = g_list_prepend(local_candidates, candidate);
+        g_object_set_data(G_OBJECT(session_a), "local-candidates", local_candidates);
+
+        g_object_set(candidate, "ufrag", local_addr, "password", stun_pass, NULL);
+    }
+}
+
+static void gathering_done(OwrSession *session)
+{
+    OwrMediaSession *msession = OWR_MEDIA_SESSION(session);
+    OwrCandidate *rtp_candidate, *rtcp_candidate;
+    GList *candidates;
+    guint l_rtp_port, l_rtcp_port, r_rtp_port, r_rtcp_port;
+
+    rtp_candidate = owr_candidate_new(OWR_CANDIDATE_TYPE_HOST, OWR_COMPONENT_TYPE_RTP);
+    rtcp_candidate = owr_candidate_new(OWR_CANDIDATE_TYPE_HOST, OWR_COMPONENT_TYPE_RTCP);
+
+    g_object_set(rtp_candidate, "address", remote_addr, "ufrag", remote_addr, "password", stun_pass, "foundation", "3", NULL);
+    g_object_set(rtcp_candidate, "address", remote_addr, "ufrag", remote_addr, "password", stun_pass, "foundation", "3", NULL);
+
+    if (msession == send_session_video) {
+        l_rtp_port = 5120;
+        l_rtcp_port = 5121;
+        r_rtp_port = 5122;
+        r_rtcp_port = 5123;
+    } else if (msession == send_session_audio) {
+        l_rtp_port = 5124;
+        l_rtcp_port = 5125;
+        r_rtp_port = 5126;
+        r_rtcp_port = 5127;
+    } else if (msession == recv_session_video) {
+        l_rtp_port = 5122;
+        l_rtcp_port = 5123;
+        r_rtp_port = 5120;
+        r_rtcp_port = 5121;
+    } else if (msession == recv_session_audio) {
+        l_rtp_port = 5126;
+        l_rtcp_port = 5127;
+        r_rtp_port = 5124;
+        r_rtcp_port = 5125;
+    }
+
+    g_object_set(rtp_candidate, "port", r_rtp_port, NULL);
+    g_object_set(rtcp_candidate, "port", r_rtcp_port, NULL);
+
+    owr_session_add_remote_candidate(session, rtp_candidate);
+    owr_session_add_remote_candidate(session, rtcp_candidate);
+
+    for (candidates = g_object_get_data(G_OBJECT(session), "local-candidates"); candidates;
+            candidates = g_list_next(candidates)) {
+        OwrCandidate *local_candidate = candidates->data, *remote_candidate;
+        OwrComponentType ctype;
+        guint port = 0;
+        gchar *addr;
+
+        g_object_get(local_candidate, "address", &addr, "port", &port, "component-type", &ctype, NULL);
+
+        if (!g_str_equal(addr, local_addr)) {
+            g_free(addr);
+            continue;
+        }
+        g_free(addr);
+
+        if (port == l_rtp_port && ctype == OWR_COMPONENT_TYPE_RTP)
+            remote_candidate = rtp_candidate;
+        else if (port == l_rtcp_port && ctype == OWR_COMPONENT_TYPE_RTCP)
+            remote_candidate = rtcp_candidate;
+        else
+            continue;
+
+        owr_session_force_candidate_pair(session, ctype, local_candidate, remote_candidate);
+    }
 }

 static void got_sources(GList *sources, gpointer user_data)
@@ -135,6 +219,13 @@
         g_assert(OWR_IS_MEDIA_SOURCE(source));

         g_object_get(source, "type", &source_type, "media-type", &media_type, NULL);
+
+        if (remote_addr) {
+            owr_transport_agent_add_helper_server(send_transport_agent, OWR_HELPER_SERVER_TYPE_STUN,
+                "stun.services.mozilla.com", 3478, NULL, NULL);
+            owr_transport_agent_add_helper_server(recv_transport_agent, OWR_HELPER_SERVER_TYPE_STUN,
+                "stun.services.mozilla.com", 3478, NULL, NULL);
+        }

         if (!disable_video && !have_video && media_type == OWR_MEDIA_TYPE_VIDEO) {
             OwrVideoRenderer *renderer;
@@ -153,6 +244,7 @@

             owr_media_session_set_send_source(send_session_video, source);

+            owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_video));
             owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_video));

             g_print("Displaying self-view\n");
@@ -177,6 +269,7 @@

             owr_media_session_set_send_source(send_session_audio, source);

+            owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_audio));
             owr_transport_agent_add_session(send_transport_agent, OWR_SESSION(send_session_audio));
             audio_source = g_object_ref(source);
         }
@@ -321,16 +414,20 @@
     g_assert(OWR_IS_TRANSPORT_AGENT(recv_transport_agent));
     owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(recv_transport_agent));

-    owr_transport_agent_set_local_port_range(recv_transport_agent, 5000, 5999);
-    owr_transport_agent_add_local_address(recv_transport_agent, "127.0.0.1");
+    owr_transport_agent_set_local_port_range(recv_transport_agent, 5120, 5127);
+    if (!remote_addr)
+        owr_transport_agent_add_local_address(recv_transport_agent, "127.0.0.1");
+    else if (local_addr)
+        owr_transport_agent_add_local_address(recv_transport_agent, local_addr);

     // SEND
     send_transport_agent = owr_transport_agent_new(TRUE);
     g_assert(OWR_IS_TRANSPORT_AGENT(send_transport_agent));
     owr_bus_add_message_origin(bus, OWR_MESSAGE_ORIGIN(send_transport_agent));

-    owr_transport_agent_set_local_port_range(send_transport_agent, 5000, 5999);
-    owr_transport_agent_add_local_address(send_transport_agent, "127.0.0.1");
+    owr_transport_agent_set_local_port_range(send_transport_agent, 5120, 5129);
+    if (!remote_addr)
+        owr_transport_agent_add_local_address(send_transport_agent, "127.0.0.1");

     if (!disable_video) {
         recv_session_video = owr_media_session_new(FALSE);
@@ -348,10 +445,26 @@
     if (!disable_video) {
         g_signal_connect(recv_session_video, "on-new-candidate", G_CALLBACK(got_candidate), send_session_video);
         g_signal_connect(send_session_video, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_video);
+        if (remote_addr) {
+            g_signal_connect(recv_session_video, "on-candidate-gathering-done", G_CALLBACK(gathering_done), send_session_video);
+            g_signal_connect(send_session_video, "on-candidate-gathering-done", G_CALLBACK(gathering_done), recv_session_video);
+	    owr_session_set_local_port(OWR_SESSION(send_session_video), OWR_COMPONENT_TYPE_RTP, 5120);
+	    owr_session_set_local_port(OWR_SESSION(send_session_video), OWR_COMPONENT_TYPE_RTCP, 5121);
+	    owr_session_set_local_port(OWR_SESSION(recv_session_video), OWR_COMPONENT_TYPE_RTP, 5122);
+	    owr_session_set_local_port(OWR_SESSION(recv_session_video), OWR_COMPONENT_TYPE_RTCP, 5123);
+        }
     }
     if (!disable_audio) {
         g_signal_connect(recv_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), send_session_audio);
         g_signal_connect(send_session_audio, "on-new-candidate", G_CALLBACK(got_candidate), recv_session_audio);
+        if (remote_addr) {
+            g_signal_connect(recv_session_audio, "on-candidate-gathering-done", G_CALLBACK(gathering_done), send_session_audio);
+            g_signal_connect(send_session_audio, "on-candidate-gathering-done", G_CALLBACK(gathering_done), recv_session_audio);
+	    owr_session_set_local_port(OWR_SESSION(send_session_audio), OWR_COMPONENT_TYPE_RTP, 5124);
+	    owr_session_set_local_port(OWR_SESSION(send_session_audio), OWR_COMPONENT_TYPE_RTCP, 5125);
+	    owr_session_set_local_port(OWR_SESSION(recv_session_audio), OWR_COMPONENT_TYPE_RTP, 5126);
+	    owr_session_set_local_port(OWR_SESSION(recv_session_audio), OWR_COMPONENT_TYPE_RTCP, 5127);
+        }
     }

     // VIDEO
@@ -363,8 +476,6 @@
         g_object_set(receive_payload, "adaptation", TRUE, NULL);

         owr_media_session_add_receive_payload(recv_session_video, receive_payload);
-
-        owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_video));
     }

     // AUDIO
@@ -373,8 +484,6 @@

         receive_payload = owr_audio_payload_new(OWR_CODEC_TYPE_OPUS, 100, 48000, 1);
         owr_media_session_add_receive_payload(recv_session_audio, receive_payload);
-
-        owr_transport_agent_add_session(recv_transport_agent, OWR_SESSION(recv_session_audio));
     }

     /* PREPARE FOR SENDING */
@@ -393,5 +502,7 @@

     owr_run();

+    g_free(remote_addr);
+
     return 0;
 }


fix sigint handling for viewer sample

fix sigint handling for viewer sample

--- samples/kvsWebRTCClientViewer.c
+++ samples/kvsWebRTCClientViewer.c
@@ -1,4 +1,6 @@
 #include "Samples.h"
+
+extern PSampleConfiguration gSampleConfiguration;

 INT32 main(INT32 argc, CHAR *argv[])
 {
@@ -24,6 +26,8 @@
         printf("[KVS Viewer] createSampleConfiguration(): operation returned status code: 0x%08x \n", retStatus);
         goto CleanUp;
     }
+    gSampleConfiguration = pSampleConfiguration;
+
     printf("[KVS Viewer] Created signaling channel %s\n", (argc > 1 ? argv[1] : SAMPLE_CHANNEL_NAME));

     // Initialize KVS WebRTC. This must be done before anything else, and must only be done once.
@@ -130,8 +134,10 @@
         goto CleanUp;
     }

-    // Block forever
-    THREAD_SLEEP(MAX_UINT64);
+    // Block until interrupted
+    while (!ATOMIC_LOAD_BOOL(&pSampleConfiguration->interrupted)) {
+        THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND);
+    }

 CleanUp:


Minor fixes

Minor fixes

--- src/high_control/manager.c
+++ src/high_control/manager.c
@@ -127,7 +127,7 @@
     reset_motion();

     //Set High level control to run at 100Hz
-    HighControlTask = task_load_data(register_event_p(register_module(&_MODULE_HIGH_CONTROL), &MotorTaskController, EVENT_PRIORITY_LOW), 100, 0, NULL);
+    HighControlTask = task_load_data(register_event_p(register_module(&_MODULE_HIGH_CONTROL), &HighLevelTaskController, EVENT_PRIORITY_LOW), 100, 0, NULL);
     task_set(HighControlTask, load_all_task());
 }


Fixed a bug of hprose_class_manager

Fixed a bug of hprose_class_manager

--- src/hprose_class_manager.c
+++ src/hprose_class_manager.c
@@ -13,7 +13,7 @@
  *                                                        *
  * hprose class manager for pecl source file.             *
  *                                                        *
- * LastModified: Mar 17, 2015                             *
+ * LastModified: Mar 19, 2015                             *
  * Author: Ma Bingyao <andot@hprose.com>                  *
  *                                                        *
 \**********************************************************/
@@ -55,7 +55,7 @@
 char * _hprose_class_manager_get_alias(char *name, int32_t len, int32_t* len_ptr TSRMLS_DC) {
     char *alias;
     hprose_bytes_io *_alias;
-    if (HPROSE_G(cache1) && (_alias = zend_hash_str_find_ptr(HPROSE_G(cache1), name, len)) == NULL) {
+    if (!HPROSE_G(cache1) || (_alias = zend_hash_str_find_ptr(HPROSE_G(cache1), name, len)) == NULL) {
         alias = estrndup(name, len);
         *len_ptr = len;
         str_replace('\\', '_', alias, len);
@@ -71,7 +71,7 @@
 char * _hprose_class_manager_get_class(char *alias, int32_t len, int32_t* len_ptr TSRMLS_DC) {
     char * name;
     hprose_bytes_io *_name;
-    if (HPROSE_G(cache2) && (_name = zend_hash_str_find_ptr(HPROSE_G(cache2), alias, len)) == NULL) {
+    if (!HPROSE_G(cache2) || (_name = zend_hash_str_find_ptr(HPROSE_G(cache2), alias, len)) == NULL) {
         name = estrndup(alias, len);
         *len_ptr = len;
         if (!class_exists(alias, len, 0) && !class_exists(alias, len, 1)) {


VPP: Only update u/v offset for some video processes

Signed-off-by: Xiang, Haihao <8d677183e5993577d4fa73a419b76987913292d6@intel.com>

--- src/i965_post_processing.c
+++ src/i965_post_processing.c
@@ -965,6 +965,45 @@
     intel_batchbuffer_end_atomic(batch);
 }

+// update u/v offset when the surface format are packed yuv
+static void i965_update_src_surface_uv_offset(
+    VADriverContextP    ctx,
+    struct i965_post_processing_context *pp_context,
+    const struct i965_surface *surface)
+{
+    struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
+    int fourcc = pp_get_surface_fourcc(ctx, surface);
+
+    if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
+        pp_static_parameter->grf1.source_packed_u_offset = 1;
+        pp_static_parameter->grf1.source_packed_v_offset = 3;
+    }
+    else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
+        pp_static_parameter->grf1.source_packed_y_offset = 1;
+        pp_static_parameter->grf1.source_packed_v_offset = 2;
+    }
+
+}
+
+static void i965_update_dst_surface_uv_offset(
+    VADriverContextP    ctx,
+    struct i965_post_processing_context *pp_context,
+    const struct i965_surface *surface)
+{
+    struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
+    int fourcc = pp_get_surface_fourcc(ctx, surface);
+
+    if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
+        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_u_offset = 1;
+        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 3;
+    }
+    else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
+        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_y_offset = 1;
+        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 2;
+    }
+
+}
+
 static void
 i965_pp_set_surface_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
                           dri_bo *surf_bo, unsigned long surf_bo_offset,
@@ -1432,6 +1471,10 @@

     pp_static_parameter->grf3.horizontal_origin_offset = src_rect->x;
     pp_static_parameter->grf3.vertical_origin_offset = src_rect->y;
+
+    // update u/v offset for packed yuv
+    i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
+    i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);

     dst_surface->flags = src_surface->flags;

@@ -3029,45 +3072,6 @@
     return VA_STATUS_SUCCESS;
 }

-// update u/v offset when the surface format are packed yuv
-static void i965_update_src_surface_uv_offset(
-    VADriverContextP    ctx,
-    struct i965_post_processing_context *pp_context,
-    const struct i965_surface *surface)
-{
-    struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
-    int fourcc = pp_get_surface_fourcc(ctx, surface);
-
-    if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
-        pp_static_parameter->grf1.source_packed_u_offset = 1;
-        pp_static_parameter->grf1.source_packed_v_offset = 3;
-    }
-    else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
-        pp_static_parameter->grf1.source_packed_y_offset = 1;
-        pp_static_parameter->grf1.source_packed_v_offset = 2;
-    }
-
-}
-
-static void i965_update_dst_surface_uv_offset(
-    VADriverContextP    ctx,
-    struct i965_post_processing_context *pp_context,
-    const struct i965_surface *surface)
-{
-    struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
-    int fourcc = pp_get_surface_fourcc(ctx, surface);
-
-    if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
-        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_u_offset = 1;
-        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 3;
-    }
-    else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
-        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_y_offset = 1;
-        pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 2;
-    }
-
-}
-
 static VAStatus
 ironlake_pp_initialize(
     VADriverContextP   ctx,
@@ -3152,10 +3156,6 @@
     memset(pp_context->pp_static_parameter, 0, static_param_size);
     memset(pp_context->pp_inline_parameter, 0, inline_param_size);

-    // update u/v offset for packed yuv
-    i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
-    i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);
-
     assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
     pp_context->current_pp = pp_index;
     pp_module = &pp_context->pp_modules[pp_index];
@@ -3291,11 +3291,8 @@

     memset(pp_context->pp_static_parameter, 0, static_param_size);
     memset(pp_context->pp_inline_parameter, 0, inline_param_size);
-    // update u/v offset for packed yuv
-    i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
-    i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);
-
-     assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
+
+    assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
     pp_context->current_pp = pp_index;
     pp_module = &pp_context->pp_modules[pp_index];


cogl_pipeline_equal: Handle COGL_WRAP_MODE_AUTOMATIC better

When comparing the wrap modes of two pipeline layers it now considers
COGL_WRAP_MODE_AUTOMATIC to be equivalent to CLAMP_TO_EDGE. By the
time the pipeline is in the journal, the upper primitive code is
expected to have overridden this wrap mode with something else if it
wants any other behaviour. This is important for getting text to batch
together with textures because the text explicitly sets the wrap mode
to CLAMP_TO_EDGE on its pipeline.

--- cogl/cogl-pipeline.c
+++ cogl/cogl-pipeline.c
@@ -3196,12 +3196,30 @@
 }

 static gboolean
+compare_wrap_mode_equal (CoglPipelineWrapMode wrap_mode0,
+                         CoglPipelineWrapMode wrap_mode1)
+{
+  /* We consider AUTOMATIC to be equivalent to CLAMP_TO_EDGE because
+     the primitives code is expected to override this to something
+     else if it wants it to be behave any other way */
+  if (wrap_mode0 == COGL_PIPELINE_WRAP_MODE_AUTOMATIC)
+    wrap_mode0 = COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE;
+  if (wrap_mode1 == COGL_PIPELINE_WRAP_MODE_AUTOMATIC)
+    wrap_mode1 = COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE;
+
+  return wrap_mode0 == wrap_mode1;
+}
+
+static gboolean
 _cogl_pipeline_layer_wrap_modes_equal (CoglPipelineLayer *authority0,
                                        CoglPipelineLayer *authority1)
 {
-  if (authority0->wrap_mode_s != authority1->wrap_mode_s ||
-      authority0->wrap_mode_t != authority1->wrap_mode_t ||
-      authority0->wrap_mode_p != authority1->wrap_mode_p)
+  if (!compare_wrap_mode_equal (authority0->wrap_mode_s,
+                                authority1->wrap_mode_s) ||
+      !compare_wrap_mode_equal (authority0->wrap_mode_t,
+                                authority1->wrap_mode_t) ||
+      !compare_wrap_mode_equal (authority0->wrap_mode_p,
+                                authority1->wrap_mode_p))
     return FALSE;

   return TRUE;
@@ -3684,6 +3702,11 @@
  * it means that _cogl_pipeline_equal doesn't strictly compare whether the
  * pipelines are the same. If we needed those semantics we could perhaps add
  * another function or some flags to control the behaviour.
+ *
+ * XXX: Similarly when comparing the wrap modes,
+ * COGL_PIPELINE_WRAP_MODE_AUTOMATIC is considered to be the same as
+ * COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE because once they get to the
+ * journal stage they act exactly the same.
  */
 gboolean
 _cogl_pipeline_equal (CoglPipeline *pipeline0,


renderer: set winsys on renderer before ->renderer_connect

When iterating through all the possible window systems trying to find
one we can successfully connect we now associated the current winsys
vtable with the renderer before calling winsys->renderer_connect in case
the implementation calls some other Cogl API that expects to be able to
determine the current winsys. For example calling _cogl_get_proc_address
when querying winsys extensions as part of a successful connect will
need to get at the current winsys vtable.

--- cogl/cogl-renderer.c
+++ cogl/cogl-renderer.c
@@ -183,6 +183,11 @@

       if (renderer_name && strcmp (winsys->name, renderer_name) != 0)
         continue;
+
+      /* At least temporarily we will associate this winsys with
+       * the renderer in-case ->renderer_connect calls API that
+       * wants to query the current winsys... */
+      renderer->winsys_vtable = winsys;

       if (!winsys->renderer_connect (renderer, &tmp_error))
         {
@@ -192,7 +197,6 @@
         }
       else
         {
-          renderer->winsys_vtable = winsys;
           renderer->connected = TRUE;
           g_string_free (error_message, TRUE);
           return TRUE;


Forgotten declaration.

Forgotten declaration.

git-svn-id: 02e3ca972ab3b5e6aa10db2b13bd0ff52712197b@35718 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/include/eina_convert.h
+++ src/include/eina_convert.h
@@ -26,6 +26,9 @@
 EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
 EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;

+EAPI int eina_convert_init(void);
+EAPI int eina_convert_shutdown(void);
+
 EAPI int eina_convert_itoa(int n, char *s);
 EAPI int eina_convert_xtoa(unsigned int n, char *s);
 EAPI int eina_convert_dtoa(double d, char *des);


removed LED from scroll lock because, scroll lock LED comes on, but not turn off

--- src/instantiations_codes.h
+++ src/instantiations_codes.h
@@ -115,7 +115,6 @@
 Code_Sc s_F12(KEY_F12);

 Code_Sc s_printscreen(KEY_PRINTSCREEN);
-//Code_Sc s_scrollLock(KEY_SCROLL_LOCK); todo
 Code_Sc s_pause(KEY_PAUSE);
 //Code_Sc s_insert(KEY_INSERT); todo
 Code_Sc s_home(KEY_HOME);
@@ -233,8 +232,14 @@
 LED_AVR LED_L1Green(PORTB, 1<<6);               //LED_0     CapsLock
 Code_LEDLock o_capsLock(KEY_CAPS_LOCK, LED_L1Green);

+/* Scroll lock LED removed because it does not turn off.
+LED does not turn off because keyboard output report USB_LED_bit not working for 4=scroll lock.
+Using scroll lock w/o LED untill keyboard output report is fixed.
+
 LED_AVR LED_L4Yellow(PORTB, 1<<7);              //LED_2     ScrollLock
 Code_LEDLock o_scrollLock(KEY_SCROLL_LOCK, LED_L4Yellow);
+*/
+Code_S o_scrollLock(KEY_SCROLL_LOCK);

 // -------------- MOUSE CODES ------------------
 Code_Mouse_Quick mq_right(1<<1);


Update forgotten comment.

Update forgotten comment.

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@2807 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/lac/include/lac/block_sparsity_pattern.h
+++ deal.II/lac/include/lac/block_sparsity_pattern.h
@@ -85,7 +85,16 @@
     BlockSparsityPattern & operator = (const BlockSparsityPattern &);

 				     /**
-				      *
+				      * This function collects the
+				      * sizes of the sub-objects and
+				      * stores them in internal
+				      * arrays, in order to be able to
+				      * relay global indices into the
+				      * matrix to indices into the
+				      * subobjects. You *must* call
+				      * this function each time after
+				      * you have changed the size of
+				      * the sub-objects.
 				      */
     void collect_sizes ();

@@ -286,18 +295,6 @@

 template <int rows, int columns>
-inline
-SparsityPattern &
-BlockSparsityPattern<rows,columns>::block (const unsigned int row,
-					   const unsigned int column)
-{
-  return sub_objects[row][column];
-};
-
-
-
-
-template <int rows, int columns>
 void
 BlockSparsityPattern<rows,columns>::collect_sizes ()
 {
@@ -338,6 +335,17 @@

 template <int rows, int columns>
 inline
+SparsityPattern &
+BlockSparsityPattern<rows,columns>::block (const unsigned int row,
+					   const unsigned int column)
+{
+  return sub_objects[row][column];
+};
+
+
+
+template <int rows, int columns>
+inline
 const SparsityPattern &
 BlockSparsityPattern<rows,columns>::block (const unsigned int row,
 					   const unsigned int column) const


Searches for ".mp3" files are now case-insensitive

--- mserv/mserv.c
+++ mserv/mserv.c
@@ -1643,7 +1643,7 @@
       strcat(filename, "/");
       mserv_scandir_recurse(filename);
     } else if (!toomany && S_ISREG(buf.st_mode)) {
-      if (llen > 4 && !strcmp(".mp3", ent->d_name+llen-4)) {
+      if (llen > 4 && !stricmp(".mp3", ent->d_name+llen-4)) {
 	if (tnum >= TRACKSPERALBUM) {
 	  mserv_log("The limit of tracks per album was reached, and some "
 		    "tracks were discarded. To increase this limit "
@@ -2066,7 +2066,7 @@
   }
   if (duration == 0 && !*miscinfo) {
     len = strlen(fullpath_file);
-    if (len > 4 && !strcmp(".mp3", fullpath_file+len-4)) {
+    if (len > 4 && !stricmp(".mp3", fullpath_file+len-4)) {
       duration = mserv_mp3info_readlen(fullpath_file, &bitrate, &id3tag);
       if (duration == -1) {
 	mserv_log("Unable to determine details of mp3 '%s': %s",


merging with mysql-5.0-bugteam

merging with mysql-5.0-bugteam

--- mysys/array.c
+++ mysys/array.c
@@ -32,11 +32,11 @@
   DESCRIPTION
     init_dynamic_array() initiates array and allocate space for
     init_alloc eilements.
-    Array is usable even if space allocation failed.
+    Array is usable even if space allocation failed, hence, the
+    function never returns TRUE.
     Static buffers must begin immediately after the array structure.

   RETURN VALUE
-    TRUE	my_malloc_ci() failed
     FALSE	Ok
 */

@@ -63,12 +63,12 @@
   array->size_of_element=element_size;
   if ((array->buffer= init_buffer))
     DBUG_RETURN(FALSE);
-  if (!(array->buffer=(uchar*) my_malloc_ci(element_size*init_alloc,
-                                            MYF(MY_WME))))
-  {
+  /*
+    Since the dynamic array is usable even if allocation fails here malloc
+    should not throw an error
+  */
+  if (!(array->buffer= (char*) my_malloc_ci(element_size*init_alloc, MYF(0))))
     array->max_element=0;
-    DBUG_RETURN(TRUE);
-  }
   DBUG_RETURN(FALSE);
 }


Plug a mem leak in GConverterOutputStream

==8221== 1,047 (672 direct, 375 indirect) bytes in 28 blocks are definitely lost in loss record 589 of 603
==8221==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
==8221==    by 0x4057094: g_malloc (gmem.c:134)
==8221==    by 0x406F2D6: g_slice_alloc (gslice.c:836)
==8221==    by 0x406F31B: g_slice_alloc0 (gslice.c:848)
==8221==    by 0x403A8A6: g_error_new_literal (gerror.c:117)
==8221==    by 0x403AC31: g_set_error_literal (gerror.c:314)
==8221==    by 0x80499DC: g_compressor_converter_convert (converter-stream.c:267)
==8221==    by 0x417BF67: g_converter_convert (gconverter.c:174)
==8221==    by 0x417D7F0: g_converter_output_stream_write (gconverteroutputstream.c:428)
==8221==    by 0x41B57DF: g_output_stream_write (goutputstream.c:216)
==8221==    by 0x804A367: test_compressor (converter-stream.c:456)

Bug #628309.

--- gio/gconverteroutputstream.c
+++ gio/gconverteroutputstream.c
@@ -477,6 +477,7 @@
 		buffer_append (&priv->output_buffer, buffer, count);
 	      /* in the converting_from_buffer case we already appended this */

+              g_error_free (my_error);
 	      return count; /* consume everything */
 	    }


gdbus-connection: Fix use after free in test

https://bugzilla.gnome.org/show_bug.cgi?id=711802

--- gio/tests/gdbus-connection.c
+++ gio/tests/gdbus-connection.c
@@ -1142,10 +1142,7 @@

   /* Wait until threads are finished */
   for (i = 0; i < NUM_THREADS; i++)
-    {
       g_thread_join (pool[i]);
-      g_thread_unref (pool[i]);
-    }

   /* No calls in between on this thread, should be the last value */
   g_assert_cmpint (g_dbus_connection_get_last_serial (c), ==, 2);


net/atm/raw.c: checkpatch cleanups

net/atm/raw.c: checkpatch cleanups

Spacing cleanups
Mostly 80 column wrapped.

Signed-off-by: Joe Perches <16a9a54ddf4259952e3c118c763138e83693d7fd@perches.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/atm/raw.c
+++ net/atm/raw.c
@@ -18,7 +18,7 @@
  * SKB == NULL indicates that the link is being closed
  */

-static void atm_push_raw(struct atm_vcc *vcc,struct sk_buff *skb)
+static void atm_push_raw(struct atm_vcc *vcc, struct sk_buff *skb)
 {
 	if (skb) {
 		struct sock *sk = sk_atm(vcc);
@@ -28,8 +28,7 @@
 	}
 }

-
-static void atm_pop_raw(struct atm_vcc *vcc,struct sk_buff *skb)
+static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
 {
 	struct sock *sk = sk_atm(vcc);

@@ -40,23 +39,21 @@
 	sk->sk_write_space(sk);
 }

-
-static int atm_send_aal0(struct atm_vcc *vcc,struct sk_buff *skb)
+static int atm_send_aal0(struct atm_vcc *vcc, struct sk_buff *skb)
 {
 	/*
 	 * Note that if vpi/vci are _ANY or _UNSPEC the below will
 	 * still work
 	 */
 	if (!capable(CAP_NET_ADMIN) &&
-	    (((u32 *) skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
-	    ((vcc->vpi << ATM_HDR_VPI_SHIFT) | (vcc->vci << ATM_HDR_VCI_SHIFT)))
-	    {
+	    (((u32 *)skb->data)[0] & (ATM_HDR_VPI_MASK | ATM_HDR_VCI_MASK)) !=
+	    ((vcc->vpi << ATM_HDR_VPI_SHIFT) |
+	     (vcc->vci << ATM_HDR_VCI_SHIFT))) {
 		kfree_skb(skb);
 		return -EADDRNOTAVAIL;
 	}
-	return vcc->dev->ops->send(vcc,skb);
+	return vcc->dev->ops->send(vcc, skb);
 }
-

 int atm_init_aal0(struct atm_vcc *vcc)
 {
@@ -67,7 +64,6 @@
 	return 0;
 }

-
 int atm_init_aal34(struct atm_vcc *vcc)
 {
 	vcc->push = atm_push_raw;
@@ -77,7 +73,6 @@
 	return 0;
 }

-
 int atm_init_aal5(struct atm_vcc *vcc)
 {
 	vcc->push = atm_push_raw;
@@ -86,6 +81,4 @@
 	vcc->send = vcc->dev->ops->send;
 	return 0;
 }
-
-
 EXPORT_SYMBOL(atm_init_aal5);


include the VLAN priority for hardware tagging, too; ok claudio@

--- net/if_vlan.c
+++ net/if_vlan.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_vlan.c,v 1.77 2008/10/16 19:18:03 naddy Exp $	*/
+/*	$OpenBSD: if_vlan.c,v 1.78 2009/01/27 15:56:58 naddy Exp $	*/

 /*
  * Copyright 1998 Massachusetts Institute of Technology
@@ -209,7 +209,8 @@
 		 * the packet along.
 		 */
 		if (p->if_capabilities & IFCAP_VLAN_HWTAGGING) {
-			m->m_pkthdr.ether_vtag = ifv->ifv_tag;
+			m->m_pkthdr.ether_vtag = ifv->ifv_tag +
+			    (ifv->ifv_prio << EVL_PRIO_BITS);
 			m->m_flags |= M_VLANTAG;
 		} else {
 			struct ether_vlan_header evh;


Fix double-free during install/update

Fix double-free during install/update

--- common/flatpak-dir.c
+++ common/flatpak-dir.c
@@ -5212,7 +5212,7 @@
   rel = g_new0 (FlatpakRelated, 1);
   rel->ref = g_strdup (extension_ref);
   rel->commit = g_strdup (checksum);
-  rel->subpaths = (char **)g_ptr_array_free (subpaths, FALSE);
+  rel->subpaths = (char **)g_ptr_array_free (g_steal_pointer (&subpaths), FALSE);
   rel->download = download;
   rel->delete = delete;


fix msvc warnings about unknown opencl pragmas

--- src/kernel/kernel_queues.h
+++ src/kernel/kernel_queues.h
@@ -22,9 +22,10 @@
 /*
  * Queue utility functions for split kernel
  */
-
+#ifdef __KERNEL_OPENCL__
 #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable
+#endif

 /*
  * Enqueue ray index into the queue


run: Remove old seccomp arch code

run: Remove old seccomp arch code

There was a merge error when we switched to bubblewrap, this
code was replaced with the code that only adds the target
arch, but we forgot to remove this old code.

--- common/flatpak-run.c
+++ common/flatpak-run.c
@@ -2582,22 +2582,6 @@
         }
     }

-  /* Add in all possible secondary archs we are aware of that
-   * this kernel might support. */
-#if defined(__i386__) || defined(__x86_64__)
-  r = seccomp_arch_add (seccomp, SCMP_ARCH_X86);
-  if (r < 0 && r != -EEXIST)
-    return flatpak_fail (error, "Failed to add x86 architecture to seccomp filter");
-
-  r = seccomp_arch_add (seccomp, SCMP_ARCH_X86_64);
-  if (r < 0 && r != -EEXIST)
-    return flatpak_fail (error, "Failed to add x86_64 architecture to seccomp filter");
-
-  r = seccomp_arch_add (seccomp, SCMP_ARCH_X32);
-  if (r < 0 && r != -EEXIST)
-    return flatpak_fail (error, "Failed to add x32 architecture to seccomp filter");
-#endif
-
   /* TODO: Should we filter the kernel keyring syscalls in some way?
    * We do want them to be used by desktop apps, but they could also perhaps
    * leak system stuff or secrets from other apps.


Cleanup: style, spelling

Cleanup: style, spelling

--- src/kernel/svm/svm_noise.h
+++ src/kernel/svm/svm_noise.h
@@ -281,7 +281,7 @@
  *    (v2, v3) is generated by moving v2 and v3 to the first and second
  *    places of the ssef using the shuffle mask <2, 3, 2, 3>. The third and
  *    fourth values are unused.
- * 2. Interplate g0 and g1 along the y axis to get the final value.
+ * 2. Interpolate g0 and g1 along the y axis to get the final value.
  *    g1 is generated by populating an ssef with the second value of g.
  *    Only the first value is important in the final ssef.
  *


Extra checks mounting /etc/{resolv.conf|localtime} without session helper

When no session helper is available (e.g. running flatpak run from a
socket-activated service unit), we need to be extra careful before
making these two files appear inside the sandbox. Otherwise, if they
are not reachable on the host system (or just symlinks to non-existent
targets), flatpak won't be able to create the sandbox, which will fail
due to a "No such file or directory error".

https://github.com/flatpak/flatpak/issues/409

--- common/flatpak-run.c
+++ common/flatpak-run.c
@@ -3120,28 +3120,41 @@
       add_args (argv_array,
                 "--symlink", "/run/host/monitor/localtime", "/etc/localtime",
                 NULL);
+      add_args (argv_array,
+                "--symlink", "/run/host/monitor/resolv.conf", "/etc/resolv.conf",
+                NULL);
     }
   else
     {
-      char localtime[PATH_MAX + 1];
-      ssize_t symlink_size;
-
-      add_args (argv_array,
-                "--bind", "/etc/resolv.conf", "/run/host/monitor/resolv.conf",
-                NULL);
-
-      symlink_size = readlink ("/etc/localtime", localtime, sizeof (localtime) - 1);
-      if (symlink_size > 0)
-        {
-          localtime[symlink_size] = 0;
+      /* /etc/localtime and /etc/resolv.conf can not exist (or be symlinks to
+       * non-existing targets), in which case we don't want to attempt to create
+       * bogus symlinks or bind mounts, as that will cause flatpak run to fail.
+       */
+      if (g_file_test ("/etc/localtime", G_FILE_TEST_EXISTS))
+        {
+          char localtime[PATH_MAX + 1];
+          ssize_t symlink_size;
+
+          symlink_size = readlink ("/etc/localtime", localtime, sizeof (localtime) - 1);
+          if (symlink_size > 0)
+            {
+              localtime[symlink_size] = 0;
+              add_args (argv_array,
+                        "--symlink", localtime, "/etc/localtime",
+                        NULL);
+            }
+          else
+            {
+              add_args (argv_array,
+                        "--bind", "/etc/localtime", "/etc/localtime",
+                        NULL);
+            }
+        }
+
+      if (g_file_test ("/etc/resolv.conf", G_FILE_TEST_EXISTS))
+        {
           add_args (argv_array,
-                    "--symlink", localtime, "/etc/localtime",
-                    NULL);
-        }
-      else
-        {
-          add_args (argv_array,
-                    "--bind", "/etc/localtime", "/etc/localtime",
+                    "--bind", "/etc/resolv.conf", "/etc/resolv.conf",
                     NULL);
         }
     }
@@ -3714,7 +3727,6 @@
             "--ro-bind", "/sys/devices", "/sys/devices",
             "--bind-data", passwd_fd_str, "/etc/passwd",
             "--bind-data", group_fd_str, "/etc/group",
-            "--symlink", "/run/host/monitor/resolv.conf", "/etc/resolv.conf",
             /* Always create a homedir to start from, although it may be covered later */
             "--dir", g_get_home_dir (),
             NULL);


[kvstore] use static_cast

[kvstore] use static_cast

--- src/kvstore/kvstore_dist.h
+++ src/kvstore/kvstore_dist.h
@@ -201,7 +201,8 @@
   void CheckUnique(const std::vector<int>& keys) {
     auto keys_copy = keys;
     auto last = std::unique(keys_copy.begin(), keys_copy.end());
-    CHECK_EQ((size_t)std::distance(keys_copy.begin(), last), (size_t)keys.size());
+    CHECK_EQ(static_cast<size_t>(std::distance(keys_copy.begin(), last)),
+             static_cast<size_t>(keys.size()));
   }

   /**
@@ -232,7 +233,7 @@
     mu_.unlock();

     if (!pskv.keys.empty()) {
-      CHECK_EQ((size_t)pskv.size, size) << "The value size cannot be changed";
+      CHECK_EQ(static_cast<size_t>(pskv.size), size) << "The value size cannot be changed";
     } else {
       auto krs = ps::Postoffice::Get()->GetServerKeyRanges();
       int num_servers = krs.size();
@@ -260,7 +261,7 @@
           pskv.lens.push_back(part_size);
           pskv.size += part_size;
         }
-        CHECK_EQ((size_t)pskv.size, size);
+        CHECK_EQ(static_cast<size_t>(pskv.size), size);
       }
     }
     return pskv;


Minor: fix linting error.

Minor: fix linting error.

--- src/labelling/clustering.h
+++ src/labelling/clustering.h
@@ -22,7 +22,8 @@

   // returns map of clusters (given by their z-value) to all their labels
   // (given as vector of label Ids).
-  std::map<float, std::vector<int>> update(Eigen::Matrix4f viewProjectionMatrix);
+  std::map<float, std::vector<int>>
+  update(Eigen::Matrix4f viewProjectionMatrix);

  private:
   std::shared_ptr<Labels> labels;


common: rlite-utils: rina_name_from_string: remove memory leak

--- common/rlite-utils.c
+++ common/rlite-utils.c
@@ -465,6 +465,7 @@
 {
     char *apn, *api, *aen, *aei;
     char *strc = COMMON_STRDUP(str, maysleep);
+    char *strc_orig = strc;
     char **strp = &strc;

     memset(name, 0, sizeof(*name));
@@ -479,12 +480,12 @@
     aei = strsep(strp, "/");

     if (!apn || !api || !aen || !aei) {
-        COMMON_FREE(strc);
+        COMMON_FREE(strc_orig);
         return -1;
     }

     __rina_name_fill(name, apn, api, aen, aei, maysleep);
-    COMMON_FREE(strc);
+    COMMON_FREE(strc_orig);

     return 0;
 }


dict client: If connect to server socket fails with EACCES, give better error message.

--- src/lib-dict/dict-client.c
+++ src/lib-dict/dict-client.c
@@ -6,6 +6,7 @@
 #include "network.h"
 #include "istream.h"
 #include "ostream.h"
+#include "eacces-error.h"
 #include "dict-private.h"
 #include "dict-client.h"

@@ -408,7 +409,13 @@
 	dict->fd = net_connect_unix(dict->path);
 	if (dict->fd == -1) {
 		dict->last_failed_connect = ioloop_time;
-		i_error("net_connect_unix(%s) failed: %m", dict->path);
+		if (errno == EACCES) {
+			i_fatal("%s", eacces_error_get("net_connect_unix",
+						       dict->path));
+		} else {
+			i_fatal("net_connect_unix(%s) failed: %m",
+				dict->path);
+		}
 		return -1;
 	}


common: Make XdgAppDir soup session initilization threadsafe

--- common/xdg-app-dir.c
+++ common/xdg-app-dir.c
@@ -2122,29 +2122,33 @@
 {
   const char *http_proxy;

-  if (self->soup_session != NULL)
-    return;
-
-  self->soup_session =
-    soup_session_new_with_options (SOUP_SESSION_USER_AGENT, "ostree ",
-                                   SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
-                                   SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
-                                   SOUP_SESSION_TIMEOUT, 60,
-                                   SOUP_SESSION_IDLE_TIMEOUT, 60,
-                                   NULL);
-  http_proxy = g_getenv ("http_proxy");
-  if (http_proxy)
-    {
-      g_autoptr(SoupURI) proxy_uri = soup_uri_new (http_proxy);
-
-      if (!proxy_uri)
-        g_warning ("Invalid proxy URI '%s'", http_proxy);
-      else
-        g_object_set (self->soup_session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
-    }
-
-  if (g_getenv ("OSTREE_DEBUG_HTTP"))
-    soup_session_add_feature (self->soup_session, (SoupSessionFeature*)soup_logger_new (SOUP_LOGGER_LOG_BODY, 500));
+  if (g_once_init_enter (&self->soup_session))
+    {
+      SoupSession *soup_session;
+
+      soup_session =
+        soup_session_new_with_options (SOUP_SESSION_USER_AGENT, "ostree ",
+                                       SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
+                                       SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
+                                       SOUP_SESSION_TIMEOUT, 60,
+                                       SOUP_SESSION_IDLE_TIMEOUT, 60,
+                                       NULL);
+      http_proxy = g_getenv ("http_proxy");
+      if (http_proxy)
+        {
+          g_autoptr(SoupURI) proxy_uri = soup_uri_new (http_proxy);
+
+          if (!proxy_uri)
+            g_warning ("Invalid proxy URI '%s'", http_proxy);
+          else
+            g_object_set (soup_session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
+        }
+
+      if (g_getenv ("OSTREE_DEBUG_HTTP"))
+        soup_session_add_feature (soup_session, (SoupSessionFeature*)soup_logger_new (SOUP_LOGGER_LOG_BODY, 500));
+
+      g_once_init_leave (&self->soup_session, soup_session);
+    }
 }

 static GBytes *


Fix to last change

Fix to last change

--- src/lib-index/mail-cache.c
+++ src/lib-index/mail-cache.c
@@ -520,7 +520,7 @@
 		    (require_same_reset_id || i == 0)) {
 			/* we want the latest cache file */
 			ret = mail_cache_reopen(cache);
-			if (ret <= 0)
+			if (ret < 0 || (ret == 0 && require_same_reset_id))
 				break;
 		}


mail_index_ext_register(): Allow registering an extension without record or header. It can still be used to register expunge/sync handlers.

--- src/lib-index/mail-index.c
+++ src/lib-index/mail-index.c
@@ -99,10 +99,9 @@
 	if (*name == '\0' || strcmp(name, str_sanitize(name, -1)) != 0)
 		i_panic("mail_index_ext_register(%s): Invalid name", name);

-	if ((default_record_size == 0 && default_hdr_size == 0) ||
-	    (default_record_size != 0 && default_record_align == 0)) {
+	if (default_record_size != 0 && default_record_align == 0) {
 		i_panic("mail_index_ext_register(%s): "
-			"Invalid record parameters", name);
+			"Invalid record alignment", name);
 	}

 	if (mail_index_ext_lookup(index, name, &ext_id))


correction in occi list operation with explicite filter value

--- comodel/genoccisql.c
+++ comodel/genoccisql.c
@@ -577,9 +577,9 @@
 			 	fprintf(h,"\t\tsprintf(buffer,%c%s = '%cu'%c,pptr->%s);\n",0x0022,iptr->name,0x0025,0x0022,iptr->name);
 			else 	fprintf(h,"\t\tsprintf(buffer,%c%s = '%cs'%c,(rest_valid_string(pptr->%s)?pptr->%s:%c%c));\n",0x0022,iptr->name,0x0025,0x0022,iptr->name,iptr->name,0x0022,0x0022);
 			fprintf(h,"\t\tif (!( xptr ))\n\t\t{\n");
-			fprintf(h,"\t\t\tif (!( xptr = allocate( strlen(separator) + strlen(buffer) + 8 ) )) { return(27); }\n");
+			fprintf(h,"\t\t\tif (!( wptr = allocate( strlen(separator) + strlen(buffer) + 8 ) )) { return(27); }\n");
 			fprintf(h,"\t\t\telse\n\t\t\t{\n");
-			fprintf(h,"\t\t\t\tsprintf(wptr,\"%cs \%cs\",xptr,separator,buffer);\n",0x0025,0x0025);
+			fprintf(h,"\t\t\t\tsprintf(wptr,\"%cs \%cs\",separator,buffer);\n",0x0025,0x0025);
 			fprintf(h,"\t\t\t\tliberate( xptr ); xptr = wptr; separator = \" AND \";\n");
 			fprintf(h,"\t\t\t}\n\t\t}\n");
 			fprintf(h,"\t\telse if (!( wptr = allocate( strlen( xptr ) + strlen( buffer ) + 8 ) )) return( 27 );\n");
@@ -589,7 +589,7 @@
 		}
 	}

-	fprintf(h,"\tif ((xptr != (char *) 0) && (!( expression.value = allocate_string(buffer)))) { return( 27 ); }\n");
+	fprintf(h,"\tif ((xptr != (char *) 0) && (!( expression.value = allocate_string(xptr)))) { return( 27 ); }\n");
 	fprintf(h,"\treturn(collect_occi_sql_records(%c%s%c,&expression));\n",0x0022,C.name,0x0022);
 	fprintf(h,"}\n");
 	return;


ALSA: asihpi - fix potential NULL pointer dereference

The dereference should be moved below the NULL test.

Signed-off-by: Wei Yongjun <b8f9cab8be13de37b9588aedad10a20fc3a68783@trendmicro.com.cn>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>


Update pyToCppModelInterfaceCache.h

Update pyToCppModelInterfaceCache.h

--- cthreeML/pyToCppModelInterfaceCache.h
+++ cthreeML/pyToCppModelInterfaceCache.h
@@ -51,10 +51,12 @@
   void setExtSourceBoundaries(const int id, const float lon_min, const float lon_max,
                               const float lat_min, const float lat_max);

-  void setExtSourceCube(const int id, const numeric::array& cube,
-                        const numeric::array& lon, const numeric::array& lat);
+  void setExtSourceCube(const int id,
+                        const boost::python::numeric::array& cube,
+                        const boost::python::numeric::array& lon,
+                        const boost::python::numeric::array& lat);

-  void setPtsSourceSpectrum(const int id, const numeric::array& spectrum);
+  void setPtsSourceSpectrum(const int id, const boost::python::numeric::array& spectrum);

   void setPtsSourcePosition(const int id, const float lon, const float lat);


ALSA: hda - Change return value for load_dsp_prepare() to -ENOSYS

Signed-off-by: Ian Minett <31d6f47bbab1421af21e8ec03c231d37f9b000c0@creativelabs.com>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/pci/hda/hda_codec.h
+++ sound/pci/hda/hda_codec.h
@@ -1165,7 +1165,7 @@
 				unsigned int size,
 				struct snd_dma_buffer *bufp)
 {
-	return 0;
+	return -ENOSYS;
 }
 static inline void
 snd_hda_codec_load_dsp_trigger(struct hda_codec *codec, bool start) {}


eina: handle properly case where str != NULL and slen == 0

SVN revision: 78222

--- src/lib/eina_stringshare.c
+++ src/lib/eina_stringshare.c
@@ -611,8 +611,10 @@
 EAPI Eina_Stringshare *
 eina_stringshare_add_length(const char *str, unsigned int slen)
 {
-   if ((!str) || (slen <= 0))
-     return NULL;
+   if (!str)
+     return NULL;
+   else if (slen == 0))
+     return "";
    else if (slen == 1)
      return (Eina_Stringshare *) _eina_stringshare_single + ((*str) << 1);
    else if (slen < 4)


ALSA: hda - Add ASRock mobo to MSI blacklist

This avoids a lockup at boot.

Signed-off-by: Michele Ballabio <6d29a3bf69c43ceb7b71ca8c4643bffed2f4d310@katamail.com>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/pci/hda/hda_intel.c
+++ sound/pci/hda/hda_intel.c
@@ -2358,6 +2358,7 @@
 static struct snd_pci_quirk msi_black_list[] __devinitdata = {
 	SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */
 	SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */
+	SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */
 	{}
 };


makefilegen: make port fix

makefilegen: make port fix

Change-Id: I22610b786ed72d55ed7bdbbac9581b1dcde10902
Signed-off-by: BenceJanosSzabo <3dbfd39ce7ec91c04ae75d8e6e61ea99d4f9b67a@ericsson.com>

--- compiler2/makefile.c
+++ compiler2/makefile.c
@@ -3833,23 +3833,28 @@
           "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES)", fp);
         }
         fprintf(fp, "\n\n"
-        "port: $(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\\\n"
+        "port:%s $(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\\\n"
         "\t$(PREPROCESSED_TTCN3_MODULES) $(BASE_PREPROCESSED_TTCN3_MODULES) "
+        "%s\\\n"
         "%s"
         "%s"
-        "%s\n"
+        "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES) %s\n"
         "\t$(TTCN3_DIR)/bin/compiler -t $(COMPILER_FLAGS) ",
+        add_refd_prjs?" referenced-check":"",
         makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"",
         makefile->linkingStrategy ? "$(BASE2_PREPROCESSED_TTCN3_MODULES) ":"",
-        makefile->nXSDModules ? "\\\n\t$(XSD2TTCN_GENERATED_MODULES) $(BASE_XSD2TTCN_GENERATED_MODULES) " : "",
-        makefile->nXSDModules && makefile->linkingStrategy ? "\\\n\t$(BASE2_XSD2TTCN_GENERATED_MODULES) " : "");
+        makefile->nXSDModules ? "\t$(XSD2TTCN_GENERATED_MODULES) $(BASE_XSD2TTCN_GENERATED_MODULES) \\\n" : "",
+        makefile->nXSDModules && makefile->linkingStrategy ? "\t$(BASE2_XSD2TTCN_GENERATED_MODULES) \\\n" : "",
+        makefile->linkingStrategy ? "$(BASE2_ASN1_MODULES) ":"");
         if (makefile->gnu_make) {
           if (add_refd_prjs) // referenced-check cannot be compiled it is not a ttcn modul
             fprintf(fp, "$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\\\n"
                         "\t$(PREPROCESSED_TTCN3_MODULES) $(BASE_PREPROCESSED_TTCN3_MODULES) "
-                        "%s\n",
+                        "%s\\\n"
+                        "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES) %s\n",
                     makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"",
-                    makefile->linkingStrategy ? "$(BASE2_PREPROCESSED_TTCN3_MODULES) ":"");
+                    makefile->linkingStrategy ? "$(BASE2_PREPROCESSED_TTCN3_MODULES) ":"",
+                    makefile->linkingStrategy ? "$(BASE2_ASN1_MODULES) ":"");
           else
             fputs("$^", fp);
         }
@@ -3857,7 +3862,8 @@
           fputs("\\\n"
           "\t$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) \\\n"
           "\t$(PREPROCESSED_TTCN3_MODULES) "
-          "$(BASE_PREPROCESSED_TTCN3_MODULES) \n", fp);
+          "$(BASE_PREPROCESSED_TTCN3_MODULES) \\\n"
+          "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES)", fp);
         }
         if (makefile->linkingStrategy && makefile->hierarchical) {
           fputs("\n\n"
@@ -3941,21 +3947,27 @@
         }

         fprintf(fp, "\n\n"
-        "port: $(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s%s%s\n"
+        "port:%s $(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\\\n"
+        "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES) %s%s %s\n"
         "\t$(TTCN3_DIR)/bin/compiler -t $(COMPILER_FLAGS) ",
+        add_refd_prjs?" referenced-check":"",
         makefile->nXSDModules ? "$(XSD2TTCN_GENERATED_MODULES) $(BASE_XSD2TTCN_GENERATED_MODULES) " : "",
         makefile->nXSDModules && makefile->linkingStrategy ? "$(BASE2_XSD2TTCN_GENERATED_MODULES) " : "",
-        makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"");
+        makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"",
+        makefile->linkingStrategy ? "$(BASE2_ASN1_MODULES) ":"");
         if (makefile->gnu_make) {
           if (add_refd_prjs) // referenced-check cannot be compiled it is not a ttcn modul
-            fprintf(fp, "$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\n",
-                    makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"");
+            fprintf(fp, "$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) %s\\\n"
+                        "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES) %s\n",
+                    makefile->linkingStrategy ? "$(BASE2_TTCN3_MODULES) ":"",
+                    makefile->linkingStrategy ? "$(BASE2_ASN1_MODULES) ":"");
           else
             fputs("$^", fp);
         }
         else {
           fputs("\\\n"
-          "\t$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) \n", fp);
+          "\t$(TTCN3_MODULES) $(BASE_TTCN3_MODULES) \\\n"
+          "\t$(ASN1_MODULES) $(BASE_ASN1_MODULES)", fp);
         }

         if (makefile->linkingStrategy && makefile->hierarchical) {
@@ -4062,12 +4074,12 @@
       fprintf(fp, "port: $(TTCN3_MODULES) %s ",
         makefile->nXSDModules ? "$(XSD2TTCN_GENERATED_MODULES) " : "");
       if (makefile->preprocess) fputs("$(PREPROCESSED_TTCN3_MODULES) ", fp);
-      fputs("\n", fp);
+      fputs("$(ASN1_MODULES)\n", fp);
       fputs("\t$(TTCN3_DIR)/bin/compiler -t $(COMPILER_FLAGS) ", fp);
       if (makefile->gnu_make) fputs("$^", fp);
       else {
         fputs("\\\n"
-              "\t$(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES)",
+              "\t$(TTCN3_MODULES) $(PREPROCESSED_TTCN3_MODULES) $(ASN1_MODULES)",
               fp);
       }


ALSA: hda - Fix a compile warning when CONFIG_PM=n

Fixed the compile warning regarding the unused function when built
with CONFIG_PM=n:
  sound/pci/hda/hda_intel.c:1905: warning: ‘snd_hda_codecs_inuse’ defined but not used

snd_hda_codecs_inuse() is used only in the resume callback.

Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/pci/hda/hda_intel.c
+++ sound/pci/hda/hda_intel.c
@@ -1900,6 +1900,12 @@
 	else if (chip->running && power_save_controller)
 		azx_stop_chip(chip);
 }
+#endif /* CONFIG_SND_HDA_POWER_SAVE */
+
+#ifdef CONFIG_PM
+/*
+ * power management
+ */

 static int snd_hda_codecs_inuse(struct hda_bus *bus)
 {
@@ -1911,14 +1917,7 @@
 	}
 	return 0;
 }
-#else /* !CONFIG_SND_HDA_POWER_SAVE */
-#define snd_hda_codecs_inuse(bus) 1
-#endif /* CONFIG_SND_HDA_POWER_SAVE */
-
-#ifdef CONFIG_PM
-/*
- * power management
- */
+
 static int azx_suspend(struct pci_dev *pci, pm_message_t state)
 {
 	struct snd_card *card = pci_get_drvdata(pci);


Don't mount directories that are already mounted, but allow subdirs

--- src/lib/mount/mount-util.c
+++ src/lib/mount/mount-util.c
@@ -60,8 +60,8 @@
             continue;
         }

-        // Check to see if mountpoint is in container (add the trailing slash to ensure we pick up directory)
-        if ( strncmp(joinpath(rootfs_dir, mountpoint), strjoin(mount, "/"), strlength(mount, 1024)+1) == 0 ) {
+        // Check to see if mountpoint is already mounted
+        if ( strcmp(joinpath(rootfs_dir, mountpoint), mount) == 0 ) {
             singularity_message(DEBUG, "Mountpoint is already mounted: %s\n", mountpoint);
             retval = 1;
             break;


[IMCC] Minor readability changes.

[IMCC] Minor readability changes.

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@20310 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- compilers/imcc/cfg.c
+++ compilers/imcc/cfg.c
@@ -786,11 +786,12 @@

     const int n = unit->n_basic_blocks;
     IMCC_info(interp, 2, "compute_dominators\n");
-    dominators = unit->dominators = malloc(sizeof (Set*) * n);
+    dominators  = unit->dominators = malloc(sizeof (Set*) * n);
     unit->idoms = malloc(sizeof (int) * n);

     dominators[0] = set_make(n);
     set_add(dominators[0], 0);
+
     for (i = 1; i < n; i++) {
         if (unit->bb_list[i]->pred_list) {
             dominators[i] = set_make_full(n);
@@ -802,11 +803,11 @@
     }

 #if USE_BFS
-    q = calloc(n, sizeof (int));
+    q       = calloc(n, sizeof (int));
     visited = set_make(n);
     set_add(visited, 0);
-    len=1;
-    cur=0;
+    len     = 1;
+    cur     = 0;

     while (cur < len) {
         Edge *edge;
@@ -830,11 +831,12 @@

         /* TODO: This 'for' should be a breadth-first search for speed */
         for (i = 1; i < n; i++) {
-            Set *s = set_copy(dominators[i]);
+            Set  *s = set_copy(dominators[i]);
             Edge *edge;

-            for (edge=unit->bb_list[i]->pred_list;
-                    edge; edge=edge->pred_next) {
+            for (edge = unit->bb_list[i]->pred_list;
+                 edge;
+                 edge = edge->pred_next) {
                 pred_index = edge->from->index;
                 set_intersec_inplace(s, dominators[pred_index]);
             }
@@ -851,8 +853,10 @@
         }
     }
 #endif
+
     /* calc idoms */
     unit->idoms[0] = unit->bb_list[0]->index;
+
     for (b = 1; b < n; b++) {
         unit->idoms[b] = 0;
         for (i = n - 1; i > 0; i--) {
@@ -868,10 +872,12 @@
                         }
                     }
                 }
+
                 if (!wrong) {
                     unit->idoms[b] = unit->bb_list[i]->index;
                     break;
                 }
+
             }
        }
    }


ALSA: HDA VIA: rename vt1708_control_templates[].

To via_control_templates[].

Signed-off-by: Lydia Wang <070ba3d7e30dfd7312770a44b7d1511cf086710e@viatech.com.cn>
Signed-off-by: Logan Li <9e209e97b16f42fd11f198d78ba308956b8fb194@viatech.com.cn>
Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/pci/hda/patch_via.c
+++ sound/pci/hda/patch_via.c
@@ -367,7 +367,7 @@
 			.put = bind_pin_switch_put,			\
 			.private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }

-static struct snd_kcontrol_new vt1708_control_templates[] = {
+static struct snd_kcontrol_new via_control_templates[] = {
 	HDA_CODEC_VOLUME(NULL, 0, 0, 0),
 	HDA_CODEC_MUTE(NULL, 0, 0, 0),
 	ANALOG_INPUT_MUTE,
@@ -430,7 +430,7 @@
 	knew = snd_array_new(&spec->kctls);
 	if (!knew)
 		return -ENOMEM;
-	*knew = vt1708_control_templates[type];
+	*knew = via_control_templates[type];
 	knew->name = kstrdup(name, GFP_KERNEL);
 	if (!knew->name)
 		return -ENOMEM;


random consting

random consting

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@37918 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- compilers/imcc/pbc.c
+++ compilers/imcc/pbc.c
@@ -316,8 +316,8 @@
     code_segment_t *cs = IMCC_INFO(interp)->globals->cs;

     while (cs) {
-        subs_t         *s       = cs->subs;
-        code_segment_t *prev_cs = cs->prev;
+        subs_t         *s              = cs->subs;
+        code_segment_t * const prev_cs = cs->prev;

         while (s) {
             subs_t * const prev_s = s->prev;
@@ -385,7 +385,7 @@
 add_const_table_pmc(PARROT_INTERP, ARGIN(PMC *pmc))
 {
     ASSERT_ARGS(add_const_table_pmc)
-    int newitem = add_const_table(interp);
+    const int newitem = add_const_table(interp);

     interp->code->const_table->constants[newitem]->type  = PFC_PMC;
     interp->code->const_table->constants[newitem]->u.key = pmc;
@@ -408,7 +408,7 @@
 add_const_table_key(PARROT_INTERP, ARGIN(PMC *key))
 {
     ASSERT_ARGS(add_const_table_key)
-    int newitem = add_const_table(interp);
+    const int newitem = add_const_table(interp);

     interp->code->const_table->constants[newitem]->type  = PFC_KEY;
     interp->code->const_table->constants[newitem]->u.key = key;
@@ -431,7 +431,7 @@
 e_pbc_open(PARROT_INTERP, SHIM(void *param))
 {
     ASSERT_ARGS(e_pbc_open)
-    code_segment_t *cs = mem_allocate_zeroed_typed(code_segment_t);
+    code_segment_t * const cs = mem_allocate_zeroed_typed(code_segment_t);

     if (!IMCC_INFO(interp)->globals)
         IMCC_INFO(interp)->globals = mem_allocate_zeroed_typed(imcc_globals);
@@ -781,7 +781,7 @@
     *pc = 0;

     for (s = IMCC_INFO(interp)->globals->cs->first; s; s = s->next) {
-        SymReg * const r = s->unit->instructions->symregs[0];
+        const SymReg * const r = s->unit->instructions->symregs[0];

         /* if names and namespaces are matching - ok */
         if (r && r->name && (strcmp(r->name, name) == 0)
@@ -817,7 +817,7 @@
     *pc = 0;

     for (s = IMCC_INFO(interp)->globals->cs->first; s; s = s->next) {
-        SymReg * const r = s->unit->instructions->symregs[0];
+        const SymReg * const r = s->unit->instructions->symregs[0];

         /* if subid matches - ok */
         if (r && (r->subid && (strcmp(r->subid, lookup) == 0)))
@@ -854,7 +854,7 @@

             for (fixup = hsh->data[i]; fixup; fixup = fixup->next) {
                 int pc, pmc_const;
-                int addr = jumppc + fixup->color;
+                const int addr = jumppc + fixup->color;
                 int subid_lookup = 0;
                 subs_t *s1;

@@ -894,11 +894,11 @@
                     }
                 }
                 if (!s1) {
-                    int op, col;
+                    int col;
                     SymReg * const nam = mk_const(interp, fixup->name,
                             fixup->type & VT_ENCODED ? 'U' : 'S');

-                    op = interp->op_lib->op_code("find_sub_not_null_p_sc", 1);
+                    const int op = interp->op_lib->op_code("find_sub_not_null_p_sc", 1);
                     PARROT_ASSERT(op);

                     interp->code->base.data[addr] = op;


simplify Resize a wee bit.

simplify Resize a wee bit.

--- src/libmv/image/array_nd.h
+++ src/libmv/image/array_nd.h
@@ -117,14 +117,10 @@
   }

   /// Resizes the array to shape s.  All data is lost.
-  void Resize(const int *shape) {
-    bool different_shape = false;
-    for ( int j = N - 1; j >= 0; --j)
-      if ( shape[j] != shape_(j) )
-        different_shape = true;
-
-    if ( different_shape ) {
-      shape_.Reset(shape);
+  void Resize(const int *shapeArray) {
+    Index newShape(shapeArray);
+    if ( shape_ != newShape ) {
+      shape_.Reset( newShape);
       strides_(N-1) = 1;
       for (int i = N - 1; i > 0; --i)
         strides_(i-1) = strides_(i) * shape_(i);


Auto merged

Auto merged

2004/10/29 15:58:32-04:00 columbia!mowery
fixed over freeing

(Logical change 1.432)

--- setools/libsefs/fsdata.c
+++ setools/libsefs/fsdata.c
@@ -278,6 +278,7 @@
 	sefs_fileinfo_t * pi = NULL;
 	char *con = NULL;
 	char *tmp = NULL;
+	char *tmp2 = NULL;
 	char** ptr = NULL;

 	key.inode = sb->st_ino;
@@ -298,9 +299,12 @@
 		/* extract the context parts */
 		tmp = strtok(con, ":");
 		if (tmp) {
+			tmp2 = (char*)malloc(sizeof(char) * (strlen(tmp) + 1));
+			strncpy(tmp2, tmp, sizeof(char) * strlen(tmp));
+			tmp2[strlen(tmp)] = '\0';
 			rc = avl_get_idx(tmp, &fsdata->user_tree);
 			if(rc == -1)
-				avl_insert(&(fsdata->user_tree),tmp, &rc);
+				avl_insert(&(fsdata->user_tree),tmp2, &rc);

 			pi->context.user=rc;
 		}
@@ -325,9 +329,12 @@

 		tmp = strtok(NULL, ":");
 		if (tmp) {
+			tmp2 = (char*)malloc(sizeof(char) * (strlen(tmp) + 1));
+			strncpy(tmp2, tmp, sizeof(char) * strlen(tmp));
+			tmp2[strlen(tmp)] = '\0';
 			rc = avl_get_idx(tmp, &fsdata->type_tree);
 			if (rc == -1) {
-				avl_insert(&(fsdata->type_tree), tmp, &rc);
+				avl_insert(&(fsdata->type_tree), tmp2, &rc);
 			}
 			pi->context.type=(int32_t)rc;
 		} else {
@@ -382,6 +389,8 @@
 			{
 				pi->symlink_target = tmp;
 			}
+		} else {
+			pi->symlink_target = NULL;
 		}

 	return 0;
@@ -974,7 +983,8 @@
 	}
 }

-void destroy_fsdata(sefs_filesystem_data_t * fsd) {
+void destroy_fsdata(sefs_filesystem_data_t * fsd)
+{
 	int i,j;

 	/* empty arrays */
@@ -1006,6 +1016,4 @@
 	avl_free(&(fsd->type_tree));
 	avl_free(&(fsd->user_tree));

-	/* destroy main structure */
-	free(fsd);
-}
+}


ASoC: lm4857: Use DAPM demux

ASoC: lm4857: Use DAPM demux

Use a DAPM auto-disable demux to model the Mode control which affects the
routing of the input pin to the output pins. This allows us to remove the
custom code for handling the Mode control.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>


[CAGE] Tab police.

[CAGE] Tab police.

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@46831 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- compilers/imcc/pbc.c
+++ compilers/imcc/pbc.c
@@ -932,7 +932,7 @@
         buf     = p + 1;
         if (strcmp(charset_name, "unicode") == 0 && strcmp(encoding_name, "utf8") == 0) {
             /* Special case needed for backward compatibility with utf8 literals
-	     * using \xHH\xHH byte sequences */
+             * using \xHH\xHH byte sequences */
             s = Parrot_str_unescape(interp, buf, '"', "utf8:unicode");
         }
         else {


call sc_select_file only if pin->path is actually set
Thanks to Andrej Komelj <akomelj@email.si>

git-svn-id: 444ed946b9c2220da791e84c3dd156a05f92db99@1784 c6295689-39f2-0310-b995-f0e70906c6a9

--- src/libopensc/pkcs15-pin.c
+++ src/libopensc/pkcs15-pin.c
@@ -186,10 +186,13 @@
 	card = p15card->card;
 	r = sc_lock(card);
 	SC_TEST_RET(card->ctx, r, "sc_lock() failed");
-	r = sc_select_file(card, &pin->path, NULL);
-	if (r) {
-		sc_unlock(card);
-		return r;
+	/* the path in the pin object is optional */
+	if (pin->path.len > 0) {
+		r = sc_select_file(card, &pin->path, NULL);
+		if (r) {
+			sc_unlock(card);
+			return r;
+		}
 	}

 	/* Initialize arguments */
@@ -254,10 +257,13 @@
 	card = p15card->card;
 	r = sc_lock(card);
 	SC_TEST_RET(card->ctx, r, "sc_lock() failed");
-	r = sc_select_file(card, &pin->path, NULL);
-	if (r) {
-		sc_unlock(card);
-		return r;
+	/* the path in the pin object is optional */
+	if (pin->path.len > 0) {
+		r = sc_select_file(card, &pin->path, NULL);
+		if (r) {
+			sc_unlock(card);
+			return r;
+		}
 	}

 	/* set pin_cmd data */
@@ -317,10 +323,13 @@
 	card = p15card->card;
 	r = sc_lock(card);
 	SC_TEST_RET(card->ctx, r, "sc_lock() failed");
-	r = sc_select_file(card, &pin->path, NULL);
-	if (r) {
-		sc_unlock(card);
-		return r;
+	/* the path in the pin object is optional */
+	if (pin->path.len > 0) {
+		r = sc_select_file(card, &pin->path, NULL);
+		if (r) {
+			sc_unlock(card);
+			return r;
+		}
 	}

 	/* set pin_cmd data */


fix cscoreFileSetCurrent

fix cscoreFileSetCurrent

--- Top/cscorfns.c
+++ Top/cscorfns.c
@@ -390,6 +390,8 @@

     a = cscoreListCreate(csound, NSLOTS);
     p = &a->e[1];
+    if (csound->scstr == NULL || csound->scstr->body[0] == '\0')
+      return a;
     while ((e = cscoreGetEvent(csound)) != NULL) {
       if (e->op == 's' || e->op == 'e')
         break;
@@ -797,7 +799,9 @@
           atEOF = infp->atEOF;
           csound->warped = infp->warped;
           if (nxtevt->op == '\0')
-            if (!(rdscor(csound, nxtevtblk))) {
+            if (csound->scstr == NULL ||
+                csound->scstr->body[0] == '\0' ||
+                !(rdscor(csound, nxtevtblk))) {
               nxtevt->op = '\0';
               atEOF = 1;
             }
@@ -929,6 +933,17 @@

 PUBLIC void cscoreFileSetCurrent(CSOUND *csound, FILE *fp)
 {
+    if (fp != NULL) {
+      CORFIL *inf = corfile_create_w();
+      int c;
+      fseek(fp, 0, SEEK_SET);
+      while ((c=getc(fp))!=EOF) corfile_putc(c, inf);
+      corfile_rewind(inf);
+      corfile_rm(&csound->scstr);
+      csound->scstr = inf;
+      nxtevt->op = csound->scstr->body[0];
+      atEOF = 0;
+    }
     if (csound->scfp != NULL)
       savinfdata(csound,
                  csound->scfp, nxtevt, curuntil, wasend, csound->warped, atEOF);


Much more comprehensive object class permissions tests

(Logical change 1.110)

--- setools/test/obj_perms.c
+++ setools/test/obj_perms.c
@@ -1,20 +1,111 @@
+/* Copyright (C) 2004 Tresys Technology, LLC
+ * see file 'COPYING' for use and warranty information */
+
 #include "test.h"
 #include "policy.h"
 #include "policy-io.h"

-policy_t *policy;
-
+/* This suite is designed to work with policy/default-v12-policy.conf */
 int main(int argc, char **argv)
 {
-	int i, num_perms;
+	int num_perms;
 	int *perms;
+	int filesystem_idx, lnk_file_idx, dir_idx;
+	bool_t errors; /* bool_t is typedef'd unsigned char */
+	char *obj_name;
+	policy_t *policy;

 	init_tests(argc, argv);
 	TEST("loading a policy", open_policy("policy/default-v12-policy.conf", &policy) == 0);
-	for (i = 0; i < policy->num_obj_classes; i++) {
-		TEST("getting perms", get_obj_class_perms(i, &num_perms, &perms, policy) == 0);
-		TEST("num perms", num_perms <= policy->num_perms);
+
+	TEST("whether get_obj_class_name returns normally", get_obj_class_name(4, &obj_name, policy) == 0);
+	TEST("whether get_obj_class_name gets the right name", strcmp(obj_name, "filesystem") == 0);
+	free(obj_name);
+
+	lnk_file_idx = get_obj_class_idx("lnk_file", policy);
+	TEST("get_obj_class_idx", lnk_file_idx == 8);
+	fprintf(stderr, "\n");
+	TEST("get_num_perms_for_obj_class w/ only common perms (lnk_file)", get_num_perms_for_obj_class(lnk_file_idx, policy) == 17);
+	TEST("get_obj_class_perms", get_obj_class_perms(lnk_file_idx, &num_perms, &perms, policy) == 0);
+	TEST("whether num_perms makes sense", num_perms <= policy->num_perms);
+	TEST("whether num_perms == get_num_perms_for_obj_class", num_perms == get_num_perms_for_obj_class(lnk_file_idx, policy));
+	{
+		errors = 17;
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("ioctl", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("read", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("write", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("create", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("getattr", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("setattr", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("lock", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("relabelfrom", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("relabelto", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("append", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("unlink", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("link", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("rename", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("execute", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("swapon", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("quotaon", policy), policy);
+		errors -= does_class_indirectly_use_perm(lnk_file_idx, get_perm_idx("mounton", policy), policy);
 	}
+	TEST("whether lnk_file's perms array is correct", errors == 0);
+	free(perms);
+	fprintf(stderr, "\n");
+	dir_idx = get_obj_class_idx("dir", policy);
+	TEST("get_num_perms_for_obj_class w/ unique and common perms (dir)", get_num_perms_for_obj_class(dir_idx, policy) == 22);
+	TEST("get_obj_class_perms", get_obj_class_perms(dir_idx, &num_perms, &perms, policy) == 0);
+	TEST("whether num_perms makes sense", num_perms <= policy->num_perms);
+	TEST("whether num_perms == get_num_perms_for_obj_class", num_perms == get_num_perms_for_obj_class(dir_idx, policy));
+	{
+		errors = 22;
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("ioctl", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("read", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("write", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("create", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("getattr", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("setattr", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("lock", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("relabelfrom", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("relabelto", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("append", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("unlink", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("link", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("rename", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("execute", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("swapon", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("quotaon", policy), policy);
+		errors -= does_class_indirectly_use_perm(dir_idx, get_perm_idx("mounton", policy), policy);
+		errors -= does_class_use_perm(dir_idx, get_perm_idx("add_name", policy), policy);
+		errors -= does_class_use_perm(dir_idx, get_perm_idx("remove_name", policy), policy);
+		errors -= does_class_use_perm(dir_idx, get_perm_idx("reparent", policy), policy);
+		errors -= does_class_use_perm(dir_idx, get_perm_idx("search", policy), policy);
+		errors -= does_class_use_perm(dir_idx, get_perm_idx("rmdir", policy), policy);
+	}
+	TEST("whether dir's perms array is correct", errors == 0);
+	free(perms);
+	fprintf(stderr, "\n");
+	filesystem_idx = get_obj_class_idx("filesystem", policy);
+	TEST("get_num_perms_for_obj_class w/ only unique perms(filesystem)", get_num_perms_for_obj_class(filesystem_idx, policy) == 10);
+	TEST("get_obj_class_perms", get_obj_class_perms(filesystem_idx, &num_perms, &perms, policy) == 0);
+	TEST("whether num_perms makes sense", num_perms <= policy->num_perms);
+	TEST("whether num_perms == get_num_perms_for_obj_class", num_perms == get_num_perms_for_obj_class(filesystem_idx, policy));
+	{
+		errors = 10;
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("mount", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("remount", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("unmount", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("getattr", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("relabelfrom", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("relabelto", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("transition", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("associate", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("quotamod", policy), policy);
+		errors -= does_class_use_perm(filesystem_idx, get_perm_idx("quotaget", policy), policy);
+	}
+	TEST("whether filesystem's perms array is correct", errors == 0);
+	free(perms);
+	fprintf(stderr, "\n");

 	return 0;
 }


ASoC: rt5645: Add ACPI match ID

ASoC: rt5645: Add ACPI match ID

This patch adds the ACPI match ID for rt5645/5650 codec

Signed-off-by: Fang, Yang A <64970d799dae4b072c7e9f48aacc13707983c54b@intel.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>


All but one error left in headerizer.  Whoo!

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@23682 d31e2699-5ff4-0310-a27c-f18f2fbe73fe