Bug 62065
| Summary: | poptGetContext declared incorrectly in popt.h | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | David Lloyd <lloy0076> |
| Component: | popt | Assignee: | Jeff Johnson <jbj> |
| Status: | CLOSED WORKSFORME | QA Contact: | |
| Severity: | low | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.1 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2002-03-27 05:52:41 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
There's no easy solution to this in C. Ideally, iIMHO, the prototype should be const char *const * argv as that, indeed, is how the variable is treated in poptGetContext. Attempting char *const * argv creates a warning of a different sort, so char ** const argv is used. |
From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 Description of problem: I asked the Linux C Programming List about this definition: | The definition is as follows: | | /*@only@*/ poptContext poptGetContext(/*@keep@*/ const char * name, | int argc, /*@keep@*/ const char ** argv, | /*@keep@*/ const struct poptOption * options, int flags); This declaration is wrong -- argv is not `const'. The Standard says: The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program [...] | int main(int argc, char *argv[]) { This is a correct declaration. | popt.c:14: warning: passing arg 3 of `poptGetContext' from | incompatible pointer type The diagnostic is correct, given the (incorrect) declaration in popt.h -- but it's the header that is wrong. Greg Version-Release number of selected component (if applicable): [lloy0076@isengard lloy0076]$ rpm -qa | grep popt popt-1.6.2-8 How reproducible: Always Steps to Reproduce: Compile this: #include <stdio.h> #include <stdlib.h> #include <popt.h> int main(int argc, char *argv[]) { int rc; char *name=malloc(sizeof(char)*256); struct poptOption opt[] = { {"username", 'u', POPT_ARG_STRING, name, 1} }; poptContext context=poptGetContext(NULL, argc, argv, opt, 0); poptGetNextOpt(context); poptFreeContext(context); return 0; } Actual Results: [lloy0076@isengard c]$ make gcc -o popt `exec gnome-config --cflags gnome` `exec gnome-config --libs gnome` popt.c popt.c: In function `main': popt.c:13: warning: passing arg 3 of `poptGetContext' from incompatible pointer type Expected Results: It should have been silent and just made an executable called "popt". Additional info: