Menu

Condition 'i<count' is always false

woko1754
2023-02-20
2023-02-20
  • woko1754

    woko1754 - 2023-02-20

    Hi, I have a piece of code, where one line is criticized with the above message, and I can't find the reason. Can this be a bug ?

    while (tx_len > 0) {
        while (bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_TX_FULL)
            ;
    
        uint32_t count = MIN(tx_len, 3);
        uint32_t data = 0;
    
          for (i = 0; i < count; ++i) {             /* <== related line */
            byte = (tx != NULL) ? (uint8_t)*tx++ : (uint8_t)0;
            data |= (uint8_t)(byte << (8 * (2 - i)));
        }
    
        data |= (count * 8) << 24;
        tx_len -= count;
    
        if (tx_len != 0)
            bcm2835_peri_write(txhold, data);
        else
            bcm2835_peri_write(io, data);
    
        while (bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_BUSY)
            ;
    
        (void)bcm2835_peri_read(io);
    }
    
     

    Last edit: woko1754 2023-02-20
  • CHR

    CHR - 2023-02-20

    I can't reproduce this with the code you posted.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.