Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7432355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:26:39+00:00 2026-05-29T09:26:39+00:00

I am struggling a bit with a compiler warning. Here the code: const char

  • 0

I am struggling a bit with a compiler warning. Here the code:

    const char *sql;
switch (fromVersion) {
    case 0:
    {
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column00 TEXT NOT NULL DEFAULT 'migrated from version 0'";
    }
    case 1:
    {
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column01 TEXT NOT NULL DEFAULT 'migrated from version 1'";
    }
    case 2:
    {
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column02 TEXT NOT NULL DEFAULT 'migrated from version 2'";
    }
    case 3:
    {                       
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column03 TEXT NOT NULL DEFAULT 'migrated from version 3'";
    }
    case 4:
    {                       
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column04 TEXT NOT NULL DEFAULT 'migrated from version 4'";
    }
    case 5:
    {                       
        sql = "ALTER TABLE abiliator_options ADD COLUMN new_column05 TEXT NOT NULL DEFAULT 'migrated from version 5'";
    }
}


sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) 
{
    if (sqlite3_step(selectstmt) == SQLITE_DONE) 
    {           
        NSLog(@"Alter statement successful");
        [self setDatabaseSchemaVersion];
    }
    else {

        NSLog(@"Failed to alter the table with message '%s'.", sqlite3_errmsg(database));
    }
}
else {
    NSLog(@"Failed to prepare the statement with message '%s'.", sqlite3_errmsg(database));

}
sqlite3_finalize(selectstmt);

First warning is Value stored to ‘sql’ is never read for all of the sql var assignments, except the last one in the switch (case 5). Case 5 does not result in a warning.

Second warning is Function call argument is an uninitialized value. This is for the
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
statement.

Thanks in advance for your hints.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:26:41+00:00Added an answer on May 29, 2026 at 9:26 am
    1. This is because you are missing break; statements between your cases.
    2. This is because you are missing a default:

    Compiler tells you that when your fromVersion is, for example, 4, whatever you assign to it in the case 4: will get immediately overwritten by case 5:, because there is no break. It also tells you that when fromVersion is negative or more than 5, your sql is uninitialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am struggling a bit with this piece of C# code. Basically, what I'm
I'm struggling a bit with traversing in jQuery. Here's the relevant markup: <ul id=sortable
I'm struggling a bit to understand why this code snippet does not compile. #include
I'm still struggling to get my sample code working on a 64 bit machine.
I am struggling a bit to figure this one out. I'm working on an
New to wpf and therefore struggling a bit. I am putting together a quick
After attending a talk on Oslo/M I am struggling a bit to see the
Sorry in advance, I'm struggling a bit with how to explain this... :) Essentially,
The problem is simple, but I'm struggling a bit already. Server server = new
This is a bit of a strange one, but I've been struggling for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.